php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45731 child pid exit Segmentation fault in putenv
Submitted: 2008-08-06 10:51 UTC Modified: 2008-11-11 12:05 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: dharmeshmaniar at rediffmail dot com Assigned:
Status: Suspended Package: Reproducible crash
PHP Version: 5.2.6 OS: ZTS only
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: dharmeshmaniar at rediffmail dot com
New email:
PHP Version: OS:

 

 [2008-08-06 10:51 UTC] dharmeshmaniar at rediffmail dot com
Description:
------------
When we use putenv in php5.2.6 it generates segmentation fault.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1390175328 (LWP 13275)]
0x009ec303 in strchr () from /lib/tls/libc.so.6

This do not happen every time. The behaviour is random.

We removed put_env from our code and everything is working properly.

No more Segmentation fault after removing putenv.

Note: We are not using any of the 3rd party apps:APC, eAccelerator, Turck MMCache, ionCube loader, Xcache, Xdebug

Actual result:
--------------
Below is the dump for gdb trace:

[New Thread -1537033312 (LWP 13289)]
[Thread -1211847776 (LWP 13258) exited]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1390175328 (LWP 13275)]
0x009ec303 in strchr () from /lib/tls/libc.so.6
(gdb) where
#0  0x009ec303 in strchr () from /lib/tls/libc.so.6
#1  0x009ace17 in putenv () from /lib/tls/libc.so.6
#2  0x003e2440 in php_putenv_destructor (pe=0xa325bb9c) at /usr/local/src/php-5.2.5/ext/standard/basic_functions.c:3861
#3  0x0049953c in zend_hash_destroy (ht=0xa35336cc) at /usr/local/src/php-5.2.5/Zend/zend_hash.c:526
#4  0x003e2e0a in zm_deactivate_basic (type=1, module_number=9, tsrm_ls=0xa39d1d28) at /usr/local/src/php-5.2.5/ext/standard/basic_functions.c:4179
#5  0x004940ba in module_registry_cleanup (module=0x9392988, tsrm_ls=0xa39d1d28) at /usr/local/src/php-5.2.5/Zend/zend_API.c:1968
#6  0x00499814 in zend_hash_apply (ht=0x601f80, apply_func=0x494098 <module_registry_cleanup>, tsrm_ls=0xa39d1d28)
    at /usr/local/src/php-5.2.5/Zend/zend_hash.c:673
#7  0x0048f753 in zend_deactivate_modules (tsrm_ls=0xa39d1d28) at /usr/local/src/php-5.2.5/Zend/zend.c:838
#8  0x00451594 in php_request_shutdown (dummy=0x0) at /usr/local/src/php-5.2.5/main/main.c:1459
#9  0x004ff862 in php_handler (r=0x95c86c0) at /usr/local/src/php-5.2.5/sapi/apache2handler/sapi_apache2.c:471
#10 0x08085f92 in ap_run_handler ()
#11 0x0808635d in ap_invoke_handler ()
#12 0x0806feb5 in ap_process_request ()
#13 0x0806b96d in _start ()
#14 0x095c86c0 in ?? ()
#15 0x00000004 in ?? ()
#16 0x095c86c0 in ?? ()
#17 0x095c86c0 in ?? ()
#18 0x0954d150 in ?? ()
#19 0x0954d060 in ?? ()
#20 0x00000000 in ?? ()



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-06 16:51 UTC] lbarnaud@php.net
This is reproducible with ZTS enabled.

Reproduce code:

$ cat /var/www/putenv.php
<?php
putenv("foo=bar");
?>
$ ab -n 10000 -c 100 http://localhost/putenv.php

 [2008-08-07 11:44 UTC] lbarnaud@php.net
The problem is currently not fixed (and is not easily fixable).

IMO environment variables should not be used in multithreaded PHP for
now, as the variables will be shared across all running scripts, which
may cause some weird behaviors. Furthermore, when a script terminates
it resets all variables set by putenv(), and as they are shared, they
are also reseted in other threads.

If you use them to pass envs to an external program, you may use
proc_open(). For other uses there are probably alternatives too. If
not, FastCGI works well.

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Mar 25 20:01:26 2019 UTC