Edit report at http://bugs.php.net/bug.php?id=53847&edit=1
ID: 53847 Updated by: ka...@php.net Reported by: ps at tns dot cz Summary: Crash after setting $field in mysql_result to NULL Status: Feedback Type: Bug Package: MySQL related Operating System: FreeBSD 8.1-RELEASE-p1 amd64 PHP Version: 5.3.5 -Assigned To: +Assigned To: kalle Block user comment: N Private report: N New Comment: Looking at the source, this could be due to a similar crash in the fetching functions with int<->long on 64bit: zif_mysql_result declares a variable called field_offset to 1. After the parameters is processed, the function will check the value of $field which will be cast to a long and put into the int variable: "field_offset = Z_LVAL_P(field);". Try changing line 1880 of ext/mysql/php_mysql.c in the latest 5.3 source (from SVN) from 'int' to 'long'. Previous Comments: ------------------------------------------------------------------------ [2011-01-30 11:07:02] ka...@php.net Could you try without the Suhosin patch (as we don't supported patched versions), and does this happen when the mysql extension is linked specifically to libmysql or mysqlnd? ------------------------------------------------------------------------ [2011-01-26 13:40:02] ps at tns dot cz Description: ------------ Assigning of value NULL to $field argument of mysql_result causes segmentation fault. PHP version: PHP 5.3.5 with Suhosin-Patch (cli) (built: Jan 10 2011 14:50:28) Installed modules: php5-ctype-5.3.5 php5-curl-5.3.5 php5-dom-5.3.5 php5-ftp-5.3.5 php5-gd-5.3.5 php5-hash-5.3.5 php5-iconv-5.3.5 php5-json-5.3.5 php5-mbstring-5.3.5 php5-mcrypt-5.3.5 php5-mysql-5.3.5 php5-mysqli-5.3.5 php5-openssl-5.3.5 php5-session-5.3.5 php5-simplexml-5.3.5 php5-soap-5.3.5 php5-tidy-5.3.5 php5-tokenizer-5.3.5 php5-xml-5.3.5 php5-zip-5.3.5 php5-zlib-5.3.5 Diff for php.ini: http://pastebin.com/5D1WsneT Test script: --------------- http://pastebin.com/2D4mVyEx Expected result: ---------------- Script should run and output nothing. Actual result: -------------- Segmentation fault. Problem is the wrong assigning of value NULL to $field argument of mysql_result on lines 13-14. Weird is that commenting out one line of for example lines 31, 32 or 33 avoids the crash. Cannot reproduce with Zend MM disabled. Cannot reproduce with PHP compiled with debug option (!). Backtrace (not useful since debug must be disabled) http://pastebin.com/KksuenGw Valgrind log (I guess not useful eighter since debug must be disabled) http://pastebin.com/vu9nsLLT ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53847&edit=1