Bug #68768 [Opn->Fbk]: Mysqli segfaults on get_result call to stored procedure using cursors

From: Date: Wed, 07 Jan 2015 18:38:41 +0000
Subject: Bug #68768 [Opn->Fbk]: Mysqli segfaults on get_result call to stored procedure using cursors
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-189706@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68768&edit=1 ID: 68768 Updated by: aharvey@php.net Reported by: yicheng at heroengine dot com Summary: Mysqli segfaults on get_result call to stored procedure using cursors -Status: Open +Status: Feedback Type: Bug Package: MySQLi related Operating System: Linux Fedora 20 PHP Version: 5.5Git-2015-01-07 (Git) Block user comment: N Private report: N New Comment: Thank you for this bug report. To properly diagnose the problem, we need a backtrace to see what is happening behind the scenes. To find out how to generate a backtrace, please read http://bugs.php.net/bugs-generating-backtrace.php for *NIX and http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32 Once you have generated a backtrace, please submit it to this bug report and change the status back to "Open". Thank you for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2015-01-07 18:32:01] yicheng at heroengine dot com Description: ------------ Given this sample stored procedure: DELIMITER // drop procedure IF EXISTS testProcedure; CREATE DEFINER=root@% PROCEDURE testProcedure(IN v_username VARCHAR(255)) MAIN:BEGIN DECLARE done INT DEFAULT 0; DECLARE p_username VARCHAR(255) DEFAULT 'default'; DECLARE sub CURSOR FOR SELECT 'Jon Jones' AS Acct_Username; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; OPEN sub; read_loop: LOOP FETCH sub INTO p_username; IF done=1 THEN LEAVE read_loop; END IF; END LOOP read_loop; CLOSE sub; SELECT 'Some kind of message' AS Msg, '200000' AS Num,CURDATE() AS current; END; // Executing the above procedure from the mysql command line retrieves the following results: MySQL [AMS]> CALL testProcedure('yicheng');// +----------------------+--------+------------+ | Msg | Num | current | +----------------------+--------+------------+ | Some kind of message | 200000 | 2015-01-07 | +----------------------+--------+------------+ 1 row in set (0.00 sec) Calling the same procedure from mysqli (e.g. the test script) will result in a segmentation fault, as shown in the following line from apache error_log: [Wed Jan 07 13:09:50.161212 2015] [core:notice] [pid 4653:tid 140193375778624] AH00052: child pid 22786 exit signal Segmentation fault (11) Curiously, taking out the select statement from the procedure will remove the segfault but will still cause a php error due to attempting to call fetch_array on a non-object. Also, if I insert another select statement before the call to OPEN sub, this will also avert the segfault although it will now cause two result sets to be returned. Test script: --------------- $mysqli = new mysqli("host", "user", "pass", "DBNAME"); $sql = "CALL testProcedure(?)"; $username = "yicheng"; $statement = $mysqli->prepare($sql); $statement->bind_param("s", $username); $statement->execute(); $result = $statement->get_result(); echo "Get Results<br/>\n"; while ($row = $result->fetch_array(MYSQLI_ASSOC)) { echo var_export($row, TRUE)."<br/>\n"; } i echo "Closing Mysqli<br/>\n"; $mysqli->close(); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=68768&edit=1

« previous php.bugs (#189706) next »