ID: 49098 Updated by: t...@php.net Reported By: bugs at timj dot co dot uk Status: Open Bug Type: Session related Operating System: Linux PHP Version: 5.2.10 New Comment:
I'm not sure if this is useful/correct, but at first pass this stops the crash: --- ext/mysqli/mysqli_nonapi.c.orig 2009-10-15 23:34:41.000000000 +0100 +++ ext/mysqli/mysqli_nonapi.c 2009-11-11 23:56:40.271496635 +0000 @@ -46,7 +46,11 @@ if (MyG(error_msg)) { efree(MyG(error_msg)); } - MyG(error_msg) = estrdup(mysql_err); + if(mysql_errno!=0) { + MyG(error_msg) = estrdup(mysql_err); + } else { + MyG(error_msg) = NULL; + } } /* }}} */ Previous Comments: ------------------------------------------------------------------------ [2009-11-11 23:55:09] t...@php.net Stepping through the code though, that patch wouldn't have made any difference. On the final incantation of php_mysqli_set_error before crash, estrdup() still gets called: Breakpoint 1, php_mysqli_set_error (mysql_errno=0, mysql_err=0x10325a7 "") at /path/to/php5.3-200911111930/ext/mysqli/mysqli_nonapi.c:44 44 { (gdb) step 45 MyG(error_no) = mysql_errno; (gdb) step 44 { (gdb) step 45 MyG(error_no) = mysql_errno; (gdb) step 46 if (MyG(error_msg)) { (gdb) step 47 efree(MyG(error_msg)); (gdb) next 49 if(mysql_err) { (gdb) step 50 MyG(error_msg) = estrdup(mysql_err); ------------------------------------------------------------------------ [2009-11-11 23:48:50] t...@php.net Nope, still the same result. (back on the 5.3 snapshot now) ------------------------------------------------------------------------ [2009-11-11 23:38:53] ras...@php.net Could you try this patch and see if it changes anything? Index: mysqli_nonapi.c =================================================================== --- mysqli_nonapi.c (revision 290565) +++ mysqli_nonapi.c (working copy) @@ -46,7 +46,11 @@ if (MyG(error_msg)) { efree(MyG(error_msg)); } - MyG(error_msg) = estrdup(mysql_err); + if(mysql_err) { + MyG(error_msg) = estrdup(mysql_err); + } else { + MyG(error_msg) = NULL; + } } /* }}} */ ------------------------------------------------------------------------ [2009-11-11 23:38:36] t...@php.net To be more specific, php_mysqli_set_error gets called twice before crashing with the same params: Starting program: /usr/local/bin/php -c /usr/local/etc php-bug49098.php [Thread debugging using libthread_db enabled] Breakpoint 1, php_mysqli_set_error (mysql_errno=0, mysql_err=0xbd1f77 "") at /path/to/php5.2-200911070930/ext/mysqli/mysqli.c:1001 1001 { (gdb) c Continuing. ok <-- *** this is program output to stdout, everything is OK here Breakpoint 1, php_mysqli_set_error (mysql_errno=0, mysql_err=0xbd1f77 "") at /path/to/php5.2-200911070930/ext/mysqli/mysqli.c:1001 1001 { (gdb) c Continuing. Program received signal SIGSEGV, Segmentation fault. _zend_mm_alloc_int (heap=0x9e02b0, size=12) at /path/to/php5.2-200911070930/Zend/zend_alloc.c:1785 1785 heap->cache[index] = best_fit->prev_free_block; ------------------------------------------------------------------------ [2009-11-11 23:30:33] t...@php.net Breakpoint 1, php_mysqli_set_error (mysql_errno=0, mysql_err=0xbd1f77 "") at /path/to/php5.2-200911070930/ext/mysqli/mysqli.c:1001 ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/49098 -- Edit this bug report at http://bugs.php.net/?id=49098&edit=1