Bug #74046 [NEW]: Segfault mysqli + libymsql + MySQL < 5.6 prepared statement fetch

From: Date: Sun, 05 Feb 2017 17:15:38 +0000
Subject: Bug #74046 [NEW]: Segfault mysqli + libymsql + MySQL < 5.6 prepared statement fetch
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207187@lists.php.net to get a copy of this message
From: deeky666 at googlemail dot com Operating system: Ubuntu 16.04 PHP version: 7.1.1 Package: Reproducible crash Bug Type: Bug Bug description:Segfault mysqli + libymsql + MySQL < 5.6 prepared statement fetch Description: ------------ Environment: - Ubuntu 16.04 - PHP 5.6 / 7.0 / 7.1 (all affected) - mysqli (compiled against libmysql, error does not occur with mysqlnd) - MySQL server < 5.6 (error does not occur since 5.6) Trying to fetch the value of an expression like "DATE_ADD(NOW(), INTERVAL 1 SECOND)" using mysqli prepared statement results in a segmentation fault. The "NOW()" expression part can be substituted by any other date related function or a datetime type column name, same result. Using a string literal like "2017-01-01" for example does not result in an error. Using "mysqli_query()" instead of a prepared statement works. Using "pdo_mysql" (libmysql) also works. Test script: --------------- $conn = new mysqli("host", "user", "password", ""); $query = "SELECT DATE_ADD(STR_TO_DATE('2017-01-01', '%Y-%m-%d'), INTERVAL 1 SECOND)"; $stmt = $conn->prepare($query); $stmt->execute(); $stmt->bind_result($value); var_dump($stmt->fetch()); Expected result: ---------------- string(19) "2017-01-01 00:00:01" Actual result: -------------- gdb backtrace: #0 0x00007ffff3a0290d in ?? () from /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 #1 0x00007ffff39f18bf in ?? () from /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 #2 0x00007ffff39f1b28 in ?? () from /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 #3 0x00007ffff39f631e in mysql_stmt_fetch () from /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20 #4 0x00007ffff359cf60 in mysqli_stmt_fetch_libmysql (execute_data=<optimized out>, return_value=0x7ffff4413140) at /tmp/php-7.1.0/ext/mysqli/mysqli_api.c:960 #5 0x00000000006e8efc in ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER () at /tmp/php-7.1.0/Zend/zend_vm_execute.h:1097 #6 0x0000000000690abb in execute_ex (ex=<optimized out>) at /tmp/php-7.1.0/Zend/zend_vm_execute.h:429 #7 0x00000000006eb340 in zend_execute (op_array=0x7ffff447f000, op_array@entry=0x7ffff4486260, return_value=return_value@entry=0x7ffff4413030) at /tmp/php-7.1.0/Zend/zend_vm_execute.h:474 #8 0x00000000006474e3 in zend_execute_scripts (type=type@entry=8, retval=0x7ffff4413030, retval@entry=0x0, file_count=file_count@entry=3) at /tmp/php-7.1.0/Zend/zend.c:1474 #9 0x00000000005e4470 in php_execute_script (primary_file=primary_file@entry=0x7fffffffd190) at /tmp/php-7.1.0/main/main.c:2533 #10 0x00000000006ed5c6 in do_cli (argc=9, argv=0xe3b680) at /tmp/php-7.1.0/sapi/cli/php_cli.c:990 #11 0x0000000000428fec in main (argc=9, argv=0xe3b680) at /tmp/php-7.1.0/sapi/cli/php_cli.c:1378 -- Edit bug report at https://bugs.php.net/bug.php?id=74046&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74046&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74046&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74046&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74046&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74046&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74046&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74046&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74046&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74046&r=support Expected behavior: https://bugs.php.net/fix.php?id=74046&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74046&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74046&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74046&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74046&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74046&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74046&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74046&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74046&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74046&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74046&r=mysqlcfg

« previous php.bugs (#207187) next »