php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17193 calling getenv after register_shutdown causes apache to crash
Submitted: 2002-05-13 19:25 UTC Modified: 2002-07-11 10:19 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: jtate@php.net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.1.2/PHP_4_2_0 OS: RH Linux 7.2/Apach 1.3.22
Private report: No CVE-ID: None
 [2002-05-13 19:25 UTC] jtate@php.net
If you call register_shutdown_function, and then in the registered function make a call to getenv, Apache segfaults.  

Here's a sample script:

<?PHP
function shutdowner()
{
    $out = fopen("/tmp/env.out", "at");
    fwrite($out, "getenv returned " . getenv("HOME") . "\n");
    fclose($out);
}

echo "Getenv returned " . getenv("HOME") . "\n";
register_shutdown_function("shutdowner");

?>

Please note.  This only happens when running as an apache module.  CLI works fine, and I'd assume that CGI does too.

I'll post a back trace if some kind soul will explain how to do it under RH linux using the messed up !apachectl method that they use to start apache.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-14 01:19 UTC] derick@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.

You can find ho wto make a backtrace on the location mentioned above.

Derick
 [2002-05-14 16:26 UTC] jtate@php.net
Here's the back trace.  Still happens with current 4_2_0 CVS.  I'm checking HEAD right now.

(gdb) bt
#0  0x00000000 in ?? ()
#1  0x403d03d6 in apache_php_module_shutdown_wrapper () at mod_php4.c:795
#2  0x08051148 in run_cleanups (c=0x8107e04) at alloc.c:1713
#3  0x0804f681 in ap_clear_pool (a=0x80903d4) at alloc.c:538
#4  0x08062f70 in standalone_main (argc=1, argv=0xbfffea94) at http_main.c:5030
#5  0x08063b24 in main (argc=1, argv=0xbfffea94) at http_main.c:5417
#6  0x401af647 in __libc_start_main (main=0x8063640 <main>, argc=1,
    ubp_av=0xbfffea94, init=0x804e3f0 <_init>, fini=0x807c770 <_fini>,
    rtld_fini=0x4000dcd4 <_dl_fini>, stack_end=0xbfffea8c)
    at ../sysdeps/generic/libc-start.c:129

It looks like register_shutdown_function is no longer performing as it has in the past.  I'll follow up this in another bug report.
 [2002-05-14 16:37 UTC] jtate@php.net
Doesn't seem to happen with HEAD.
 [2002-07-11 02:59 UTC] sniper@php.net
If it doesn't happen with HEAD..why is this report still open? :)

 [2002-07-11 10:19 UTC] jtate@php.net
As long as there isn't another 4.2 release we're fine.  Otherwise, there's still an open bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 21:01:26 2024 UTC