php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31349 Segmentation fault in mysql_query()
Submitted: 2004-12-30 11:56 UTC Modified: 2005-01-09 01:00 UTC
From: bugs dot php dot net at chsc dot dk Assigned:
Status: No Feedback Package: MySQL related
PHP Version: 5.0.3 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2004-12-30 11:56 UTC] bugs dot php dot net at chsc dot dk
Description:
------------
I have a rather complex script that dumps core every time mysql_query() is called for the 7th time (through PEAR's DB_mysql).

The script uses Smarty, PEAR_DB and a bunch of other classes. I have not been able to make a simple testcase. Doing the seven SQL queries alone without Smarty and all the other code does not trigger this bug. I hope that a stack trace will point in the right direction though.

The problem occurs with two different MySQL versions:
mysql  Ver 12.22 Distrib 4.0.20, for pc-linux (i686)
mysql  Ver 14.7 Distrib 4.1.8, for pc-linux (i686)

The problem can be reproduced on two different machines.

I am using PHP 5.0.3. The problem wasn't there with PHP 5.0.2.

PHP was configured like this:
'./configure' '--with-mysql=/usr/local/mysql' '--with-apache=../apache' '--enable-track-vars' '--with-gettext' '--with-dom' '--with-mcrypt' '--with-gd' '--with-jpeg-dir' '--with-png-dir' '--with-zlib-dir' '--with-freetype-dir' '--with-pear' '--enable-mbstring' '--with-iconv' '--disable-debug' '--enable-soap'


This is a stacktrace of the failure:

# gdb /usr/local/apache/bin/httpd
GNU gdb 2002-04-01-cvs
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-linux"...(no debugging symbols found)...
(gdb) run -X
Starting program: /usr/local/apache/bin/httpd -X
(no debugging symbols found)...[New Thread 1024 (LWP 31535)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 31535)]
0x403d61b7 in memcpy () from /lib/libc.so.6
(gdb) bt
#0  0x403d61b7 in memcpy () from /lib/libc.so.6
#1  0x0829a104 in cli_read_rows ()
#2  0x0829b942 in mysql_close ()
#3  0x0829ba50 in mysql_real_query ()
#4  0x0817446e in zif_mysql_client_encoding ()
#5  0x0817460c in zif_mysql_client_encoding ()
#6  0x08174630 in zif_mysql_query ()
#7  0x08113a5a in zend_do_fcall_common_helper ()
#8  0x08114091 in zend_do_fcall_handler ()
#9  0x080fc375 in execute ()
#10 0x08113b42 in zend_do_fcall_common_helper ()
#11 0x08113e99 in zend_do_fcall_by_name_handler ()
#12 0x080fc375 in execute ()
#13 0x08113b42 in zend_do_fcall_common_helper ()
#14 0x08113e99 in zend_do_fcall_by_name_handler ()
#15 0x080fc375 in execute ()
#16 0x08113b42 in zend_do_fcall_common_helper ()
#17 0x08113e99 in zend_do_fcall_by_name_handler ()
#18 0x080fc375 in execute ()
#19 0x08113b42 in zend_do_fcall_common_helper ()
#20 0x08113e99 in zend_do_fcall_by_name_handler ()
#21 0x080fc375 in execute ()
#22 0x08113b42 in zend_do_fcall_common_helper ()
---Type <return> to continue, or q <return> to quit---
#23 0x08113e99 in zend_do_fcall_by_name_handler ()
#24 0x080fc375 in execute ()
#25 0x08113b42 in zend_do_fcall_common_helper ()
#26 0x08113e99 in zend_do_fcall_by_name_handler ()
#27 0x080fc375 in execute ()
#28 0x08113b42 in zend_do_fcall_common_helper ()
#29 0x08113e99 in zend_do_fcall_by_name_handler ()
#30 0x080fc375 in execute ()
#31 0x08113b42 in zend_do_fcall_common_helper ()
#32 0x08113e99 in zend_do_fcall_by_name_handler ()
#33 0x080fc375 in execute ()
#34 0x08113b42 in zend_do_fcall_common_helper ()
#35 0x08113e99 in zend_do_fcall_by_name_handler ()
#36 0x080fc375 in execute ()
#37 0x08118cd6 in zend_include_or_eval_handler ()
#38 0x080fc375 in execute ()
#39 0x08113b42 in zend_do_fcall_common_helper ()
#40 0x08113e99 in zend_do_fcall_by_name_handler ()
#41 0x080fc375 in execute ()
#42 0x08118cd6 in zend_include_or_eval_handler ()
#43 0x080fc375 in execute ()
#44 0x08113b42 in zend_do_fcall_common_helper ()
#45 0x08113e99 in zend_do_fcall_by_name_handler ()
---Type <return> to continue, or q <return> to quit---
#46 0x080fc375 in execute ()
#47 0x08113b42 in zend_do_fcall_common_helper ()
#48 0x08113e99 in zend_do_fcall_by_name_handler ()
#49 0x080fc375 in execute ()
#50 0x08113b42 in zend_do_fcall_common_helper ()
#51 0x08113e99 in zend_do_fcall_by_name_handler ()
#52 0x080fc375 in execute ()
#53 0x08113b42 in zend_do_fcall_common_helper ()
#54 0x08113e99 in zend_do_fcall_by_name_handler ()
#55 0x080fc375 in execute ()
#56 0x080e1a68 in zend_execute_scripts ()
#57 0x080b98da in php_execute_script ()
#58 0x0811b712 in apache_php_module_main ()
#59 0x080b22f2 in ssl_expr_yyinput ()
#60 0x080b2341 in ssl_expr_yyinput ()
#61 0x0825b364 in ap_invoke_handler ()
#62 0x0826b74c in ap_some_auth_required ()
#63 0x0826ba50 in ap_internal_redirect ()
#64 0x08096c6c in ap_get_server_built ()
#65 0x0825b364 in ap_invoke_handler ()
#66 0x0826b74c in ap_some_auth_required ()
#67 0x0826b7a8 in ap_process_request ()
#68 0x08264d57 in ap_child_terminate ()
---Type <return> to continue, or q <return> to quit---
#69 0x08264ef4 in ap_child_terminate ()
#70 0x08265019 in ap_child_terminate ()
#71 0x0826556d in ap_child_terminate ()
#72 0x08265c7d in main ()
#73 0x4037a14f in __libc_start_main () from /lib/libc.so.6
(gdb)



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-30 14:44 UTC] bugs dot php dot net at chsc dot dk
I appears that if I change the queries slightly, e.g. add a /* comment */ to the end of the SQL string, or remove additional whitespace outsite strings, everything works as expected.

It may be related to this bug: http://bugs.mysql.com/bug.php?id=5607
 [2004-12-31 03:43 UTC] iliaa@php.net
Please compile your PHP with debugging symbols and re-run the crash script.
 [2005-01-09 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Dec 01 07:03:34 2021 UTC