php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33832 segfault with PDO_MYSQL_ATTR_USE_BUFFERED_QUERY
Submitted: 2005-07-23 03:25 UTC Modified: 2005-07-24 02:40 UTC
From: james at safesearching dot com Assigned:
Status: Closed Package: PDO related
PHP Version: 5.1.0b3 OS: *
Private report: No CVE-ID: None
 [2005-07-23 03:25 UTC] james at safesearching dot com
Description:
------------
Getting a segfault with the PDO_MYSQL_ATTR_USE_BUFFERED_QUERY attribute set to true.

$db = new PDO;
$stmt = $db->prepare();
$stmt->execute();
$db->prepare();

... the above fills PDO::errorInfo() with an error "Cannot execute queries while other unbuffered queries are active.  Consider using PDOStatement::fetchAll().  Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO_MYSQL_ATTR_USE_BUFFERED_QUERY attribute."

When calling $db->setAttribute(PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, true) I get a segfault.

Calling $stmt->closeCursor() after the first execute with the USE_BUFFERED_QUERY attribute still 'causes a segfault. Without the USE_BUFFERED_QUERY attribute, the above error goes away, there's not segfault, and everything works as expected.

Reproduce code:
---------------
$db = new PDO(
        'mysql:dbname=test;host=localhost',
        'user',
        'secret'
);

$db->setAttribute(PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, true);

$stmt = $db->prepare('SHOW TABLES');
$stmt->execute();
$stmt = $db->prepare('SHOW TABLES');

print_r($db->errorInfo());

Expected result:
----------------
No segfault

Actual result:
--------------
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 30628)]
0x080c6085 in pdo_mysql_stmt_execute (stmt=0x84c5b14)
    at /home/james/php/ext/pdo_mysql/mysql_statement.c:102
102                                             switch (S->fields[i].type) {
(gdb) bt
#0  0x080c6085 in pdo_mysql_stmt_execute (stmt=0x84c5b14)
    at /home/james/php/ext/pdo_mysql/mysql_statement.c:102
#1  0x080c0979 in zif_PDOStatement_execute (ht=0, return_value=0x84c5a3c,
    return_value_ptr=0x0, this_ptr=0x84c5ab4, return_value_used=0)
    at /home/james/php/ext/pdo/pdo_stmt.c:395
#2  0x081bdb97 in execute_internal (execute_data_ptr=0xbfffced0,
    return_value_used=0) at /home/james/php/Zend/zend_execute.c:1324
#3  0x40409795 in xdebug_execute_internal (current_execute_data=0xbfffced0,
    return_value_used=0) at /home/james/xdebug/xdebug.c:1223
#4  0x081be08b in zend_do_fcall_common_helper_SPEC (execute_data=0xbfffced0)
    at /home/james/php/Zend/zend_vm_execute.h:186
#5  0x081bdca1 in execute (op_array=0x84c5584)
    at /home/james/php/Zend/zend_vm_execute.h:87
#6  0x404095c8 in xdebug_execute (op_array=0x84c5584)
    at /home/james/xdebug/xdebug.c:1166
#7  0x081a09b4 in zend_execute_scripts (type=8, retval=0x0, file_count=3)
    at /home/james/php/Zend/zend.c:1087
#8  0x08170916 in php_execute_script (primary_file=0xbffff2d0)
    at /home/james/php/main/main.c:1672
#9  0x08235154 in main (argc=2, argv=0xbffff384)
    at /home/james/php/sapi/cli/php_cli.c:1039
#10 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-23 04:22 UTC] wez@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

I think that Ilia already fixed this in CVS; please try a snapshot.
 [2005-07-24 02:40 UTC] james at safesearching dot com
Works in CVS.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 19 15:03:37 2021 UTC