Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45928 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32047 invoked from network); 1 Nov 2009 21:21:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Nov 2009 21:21:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=scott@macvicar.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=scott@macvicar.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain macvicar.net from 97.107.131.220 cause and error) X-PHP-List-Original-Sender: scott@macvicar.net X-Host-Fingerprint: 97.107.131.220 whisky.macvicar.net Linux 2.6 Received: from [97.107.131.220] ([97.107.131.220:36477] helo=whisky.macvicar.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 17/42-17998-2DBFDEA4 for ; Sun, 01 Nov 2009 16:21:23 -0500 Received: from [10.23.137.170] (unknown [82.132.139.198]) by whisky.macvicar.net (Postfix) with ESMTP id 4CDBF4695D; Sun, 1 Nov 2009 16:21:20 -0500 (EST) References: <61.F1.17998.729FDEA4@pb1.pair.com> Message-ID: To: Mark Skilbeck In-Reply-To: <61.F1.17998.729FDEA4@pb1.pair.com> Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Mailer: iPhone Mail (7A341) Mime-Version: 1.0 (iPhone Mail 7A341) Date: Sun, 1 Nov 2009 21:21:14 +0000 Cc: "internals@lists.php.net" Subject: Re: [PHP-DEV] Seg fault when using active_symbol_table called from userspace function. From: scott@macvicar.net (Scott MacVicar) On 1 Nov 2009, at 21:09, Mark Skilbeck wrote: > Can you explain to me why the following causes a segfault: > > [code] > PHP_FUNCTION(sample_var_a_exists) > { > if (!zend_hash_exists(EG(active_symbol_table), "a", sizeof("a"))) { > RETURN_BOOL(0); > } > RETURN_BOOL(1); > } > [/code] > > Note: the segfault only occurs when the sample_var_a_exists function > is called from within a userspace function: > > [code] > $a = ''; > var_dump(sample_var_a_exists()); // bool(true) > > function x() { > var_dump(sample_var_a_exists()); // segmentation fault > } > > x() There is no symbol table as there are no variables. You should check if it's NULL before using zend_hash_exists. Scott