php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26478 Segfault under load with scripts that call MySQL
Submitted: 2003-11-30 19:16 UTC Modified: 2004-01-01 01:00 UTC
Votes:4
Avg. Score:3.8 ± 0.8
Reproduced:3 of 4 (75.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: fillmore at nrcan dot gc dot ca Assigned:
Status: No Feedback Package: MySQL related
PHP Version: 4.3.4 OS: Solaris 8 (SPARC)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fillmore at nrcan dot gc dot ca
New email:
PHP Version: OS:

 

 [2003-11-30 19:16 UTC] fillmore at nrcan dot gc dot ca
Description:
------------
PHP 4.3.4 --with-nsapi (and 4.3.2) segfaults when many
simultaneous requests are made to a script that calls MySQL.  It fails under both SunONE Web Server 6.0 and 6.1 with:
[30/Nov/2003:18:39:36] catastrophe ( 2877): Server crash detected (signal SIGBUS)
[30/Nov/2003:18:39:36] info ( 2877): Crash occurred in NSAPI SAF php4_execute
[30/Nov/2003:18:39:36] info ( 2877): Crash occurred in function _db_return_ from module /sunone/bin/libphp4.so

It only happens if a load test is run with more than about
30 simultaneous users.  It does not appear to be a
multithreading problem- it still fails with all CPUs
except one shut off.

- Bob Fillmore



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-30 19:23 UTC] iliaa@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.

When generating a backtrace make sure your PHP has been compiled with --enable-debug.
 [2003-12-04 17:09 UTC] fillmore at nrcan dot gc dot ca
There is no core file produced for process that crashes
(not sure why), so I used truss to stop the process
when it gets a FLTACCESS fault (bus or alignment error),
then used pstack to do a stack trace of all the lightweight
processes (threads), and here is the one for _db_return_:

-----------------  lwp# 17 / thread# 27  --------------------
 fe4fa5c0 _db_return_ (b4, fd2bde9c, fd2bde98, fd2bde94, fd2bde98, fd2bde94) + 1
98
 fe4eff98 vio_read (4, 105cb18, 4, 434c, fd2bdf38, 434c) + 144
 fe4ef8f4 my_real_read (105c698, 434c, 950, 948, fe67ffa0, 2) + e4
 fe4efc10 my_net_read (105c698, 8, 1, 0, 1bb9c, fea973e4) + 8
 fe4ea5b8 net_safe_read (105c698, fe6176c0, 6cc, fd2be0ac, fd2be0a8, fd2be0a4) +
 50
 fe4ed2cc mysql_read_query_result (105c698, fd2be134, fd2be130, fd2be12c, 1, fd2
be12c) + 50
 fe4ed5a4 mysql_real_query (105c698, 10754a8, 93, 105c560, 0, 2) + f8
 fe4e6e9c php_mysql_do_query_general (d95398, 105c698, 2, 0, 4000, 105c5a8) + 46
4
 fe4e70e0 php_mysql_do_query (1, 105c5a8, 0, 1, d7d178, 1) + d0
 fe4e7108 zif_mysql_query (1, 105c5a8, 0, 1, d7d178, fe4e70f0) + 18
 fe5ff208 execute  (10611d8, d7d178, fd2be8e0, 3c00, d828c8, db79a8) + 63cc
 fe5e7de4 zend_execute_scripts (fe69f0a4, d7d178, 0, 3, fe69f404, fd2c1274) + 12
4
 fe5abdcc php_execute_script (0, d7d178, 8000, a92340, d828cc, 65) + 334
 fe609370 php4_execute (5de4c8, a4fd98, a4fde0, 4000, 0, 4000) + 4b4
 ff239244 __0FNfunc_exec_strP6KFuncStructP6GpblockP6HSessionP6HRequest (6b7c8, 5
de4c8, a4fd98, a4fde0, 633, 0) + 1f0
 ff23a434 INTobject_execute (5dfec8, a4fd98, a4fde0, a418c8, a4fce8, ff308000) +
 56c
 ff23e0b4 INTservact_service (a4fd98, a4fde0, 0, 0, 0, ff308400) + 444
 ff23e608 INTservact_handle_processed (a4fd98, a4fde0, 1, 5d2420, fffffffc, 0) +
 140
 ff27308c __0fLHttpRequestUUnacceleratedRespondPCcPc (a4fce8, a91478, ff317fd8,
a4fde0, a4fd98, ff317c00) + 4e8
 ff27268c __0fLHttpRequestNHandleRequestP6Gnetbuf (a4fce8, a91490, a91478, 2000,
 a8f460, ff317c00) + 590
 ff270e3c __0fNDaemonSessionDrunv (a418c8, ff317800, ff317800, ff2720fc, ffffe80
0, 0) + 40c
 ff11407c ThreadMain (a418c8, ff114054, feb4e000, 8, a502c8, 0) + 28
 fed67698 _pt_root (a502c8, fed81074, 1, 5, 1, fe401000) + a4
 feb3b744 _thread_start (a502c8, 0, 0, 0, 0, 0) + 40
 [2003-12-07 16:08 UTC] fillmore at nrcan dot gc dot ca
I finally captured a core file, and with the gdb command
"info threads" got this output for thread 25:
  49 Thread 25 (LWP 17)  _db_return_ (_line_=949, _sfunc_=0xfd3ee01c,
    _sfile_=0xfd3ee018, _slevel_=0xfd3ee014)
    at /home8/src/php/php-4.3.4/ext/mysql/libmysql/dbug.c:826

I can't get a full backtrace using "bt", maybe because
the SunONE modules don't have debug symbols?
I'm not very familiar with gdb - how do you run bt
for a specified thread?  I tried "thread 25" followed by
"bt", but it traced libthread.so:
(gdb) thread 25
[Switching to thread 25 (Thread 1        )]
#0  0xfeb2826c in cond_wait () from /usr/lib/libthread.so.1
(gdb) bt
#0  0xfeb2826c in cond_wait () from /usr/lib/libthread.so.1
#1  0xfeb28118 in pthread_cond_wait () from /usr/lib/libthread.so.1
#2  0xfed61a94 in PR_WaitCondVar ()
   from /export/home/local/sunone/bin/https/lib/libnspr4.so
#3  0xff298084 in __0fJWebServerDRunvT ()
   from /export/home/local/sunone/bin/https/lib/libns-httpd40.so
#4  0x10c44 in main ()
 [2003-12-09 06:14 UTC] sniper@php.net
Please try compiling PHP with the external mysql client library, using --with-mysql=/mysql/install/prefix

 [2003-12-16 14:47 UTC] fillmore at nrcan dot gc dot ca
I installed MySQL client libraries 4.0.15 and rebuilt PHP
with --with-mysql=/usr/local/mysql, and now the PHP script
is failing with:
"Warning: mysql_connect(): Can't connect to MySQL server on 'aaa.bbb.xx.yy' (2) in /home1/fast1/WWW-data/cfs-scf/national/what-quoi/Solutions/index_e.php on line 7"
(IP address is obscured as aaa.bbb.xx.yy)
It works OK with the builtin MySQL support (with light load).
 [2003-12-16 14:57 UTC] sniper@php.net
Please check your mysql settings.. (my.cnf for starters)

 [2004-01-01 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over 2 weeks, 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".
 [2005-03-17 02:10 UTC] michaelw at webcentral dot com dot au
I can duplicate this using PHP 4.3.10 with MySQL 3.23.58 under SunONE 6.1 under Solaris 9. 

(incidently, the fix for the 'unable to connect' issue mentioned is to set CFLAGS to include -D_REENTRANT )

I can give you any additional information you require, if you can tell me how :)
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Sep 24 01:03:38 2021 UTC