Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:17238 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 640 invoked by uid 1010); 12 Jul 2005 04:42:14 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 625 invoked from network); 12 Jul 2005 04:42:14 -0000 Received: from unknown (HELO pb1.pair.com) (127.0.0.1) by localhost with SMTP; 12 Jul 2005 04:42:14 -0000 X-Host-Fingerprint: 69.56.217.178 unknown Linux 2.4/2.6 Received: from ([69.56.217.178:48403] helo=coggeshall.org) by pb1.pair.com (ecelerity 1.2 r(5656M)) with SMTP id 7C/6E-23681-42A43D24 for ; Tue, 12 Jul 2005 00:42:13 -0400 Received: from [192.168.1.100] (72-254-39-41.client.stsn.net [72.254.39.41]) (authenticated bits=0) by coggeshall.org (8.12.8/8.12.8) with ESMTP id j6C3uNLO029840 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); Mon, 11 Jul 2005 22:56:24 -0500 To: Jessie Hernandez Cc: internals@lists.php.net In-Reply-To: <32.3E.23681.9C843D24@pb1.pair.com> References: <32.3E.23681.9C843D24@pb1.pair.com> Content-Type: text/plain Date: Tue, 12 Jul 2005 00:41:51 -0400 Message-ID: <1121143311.6279.2.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.4 (2.0.4-4) Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Interesting zend_executor_globals Find... From: john@coggeshall.org (John Coggeshall) Perhaps this is the obvious answer, but I'm pretty sure a fair number of structures used in the engine are, memory-space wise, portions of larger structures defined elsewhere. This allows the larger structure to be type-cast to a smaller structure for certain operations easily. It is possible that the _zend_executor_globals struct is one of these cases (although I'm not certain without digging through the code), which means the placement of variables within the struct is important. John On Tue, 2005-07-12 at 00:36 -0400, Jessie Hernandez wrote: > 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 >