#19243 [NEW]: Seg Fault Restoring Session Variables with References to Objects

From: Date: Thu, 05 Sep 2002 10:03:07 +0000
Subject: #19243 [NEW]: Seg Fault Restoring Session Variables with References to Objects
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-18478@lists.php.net to get a copy of this message
From: fdruseikis@sc.rr.com Operating system: Linux RH 7.0 PHP version: 4.2.2 PHP Bug Type: Reproducible crash Bug description: Seg Fault Restoring Session Variables with References to Objects The following script demonstrates a problem with restoring session variables that have references to objects. Variables o1 and o2 are supposed to be globals refering to the same object instance. First GET request initializes; POST request changes state. Crash occurs on first POST or second GET. Apache 1.3.26 reports a segmentation fault. Browser (lynx) indicates "Unexpected Network Read Error; ..." If you remove 'o2' from session_register() and initialize the reference to o1 in the POST the crash goes away. Fred Druseikis -------------------- <snip> ----------------------------- <?php # vim: ts=4 filetype=php # segmentation fault on restore of object references class TFoo { var $c; function TFoo($c) { $this->c = $c; } function inc() { $this->c++; } } global $o1, $o2; session_register('o1', 'o2' ); session_start(); if( $_SERVER['REQUEST_METHOD'] == 'GET' ) { echo "GET<br>"; $o1 =& new TFoo(42); $o2 =& $o1; } if( $_SERVER['REQUEST_METHOD'] == 'POST' ) { echo "POST<br>"; } $o1->inc(); $o2->inc(); echo "<tt>o1</tt><br><pre>"; print_r($o1); echo "</pre>"; echo "<tt>o2</tt><br><pre>"; print_r($o2); echo "</pre>"; ?> <html> <head> </head> <body> <form action='/web/a/register/foo.php' method='post' > <input type='text' name='x' value='42' /> <input type='submit' name='submit' value='Submit' /> </form> </body> </html> -- Edit bug report at http://bugs.php.net/?id=19243&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=19243&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=19243&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=19243&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=19243&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=19243&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=19243&r=support Expected behavior: http://bugs.php.net/fix.php?id=19243&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=19243&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=19243&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=19243&r=globals

« previous php.bugs (#18478) next »