Interesting zend_executor_globals Find...

From: Date: Tue, 12 Jul 2005 04:36:22 +0000
Subject: Interesting zend_executor_globals Find...
Groups: php.internals 
Request: Send a blank email to internals+get-17237@lists.php.net to get a copy of this message
Today I've been debugging a segfault with my namespace patch until I found that the problem was simply the placement of a variable in a struct. I still don't see the logic behind it, but I got the segfault both in Windows 2000 and Linux (FC3). The steps to reproduce this segfault are very simple (using PHP 5.1.0b2): 1) In zend_globals.h, modify the struct _zend_executor_globals and add a simple HashTable pointer after class_table or zend_constants. It should look like this: ... HashTable *class_table; /* class table */ HashTable *my_hash; HashTable *zend_constants; /* constants table */ 2) Compile PHP. Now any script you execute will produce a segmentation fault. 3) Move your hash table to the end of the struct, right before the "reserved" array: HashTable *my_hash; void *reserved[ZEND_MAX_RESERVED_RESOURCES]; 4) make clean (or simply delete all the *.o and *.lo files under Zend/) and compile PHP again. All executed scripts work as usual, and no segfault is produced. Does anyone know why this happens? Regards, Jessie Hernandez

« previous php.internals (#17237) next »