Newsgroups: php.internals,php.pecl.dev Path: news.php.net Xref: news.php.net php.internals:63526 php.pecl.dev:9908 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67182 invoked from network); 18 Oct 2012 10:56:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Oct 2012 10:56:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.170 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.220.170 mail-vc0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:33981] helo=mail-vc0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A4/F8-30095-370EF705 for ; Thu, 18 Oct 2012 06:56:52 -0400 Received: by mail-vc0-f170.google.com with SMTP id fo14so9890609vcb.29 for ; Thu, 18 Oct 2012 03:56:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=xuMwVmbGUnRxrDchVvDUCAb/DMfLMhc2tEZMskcfGU8=; b=lobWTD3zDL0DUd6CtWHj2zyD507zFWeR01ejR1//g21GQ4uFtQLPb4pYHG1l0bm8Fo RfVfyUh7o43zdsk7UOfLSaGYGFEQemGInjsHEaqdoOgKkoHJFyrgXlWH5e+9L8PytnBn T3GyGa/bAfU+pi/UPLokwbx2vYn9jSpJYy9xJvV9lqTy1udEPE1eFxYHy6UIPpU1zUMT Z8om7dJjjEtieh112IDJkW81IgQciZQg+SsQB/b8D2cYP75fbelEylW5Fh+ZMjg93KRy r0SVbnhscAUbUQg1kva3pxoowTfJae4LkyVDU0Jrn+Rd9InNBiB51kG0wYSym0xInKSv 4fCQ== Received: by 10.52.34.42 with SMTP id w10mr11703009vdi.10.1350557808873; Thu, 18 Oct 2012 03:56:48 -0700 (PDT) MIME-Version: 1.0 Sender: laruence@gmail.com Received: by 10.221.12.8 with HTTP; Thu, 18 Oct 2012 03:56:28 -0700 (PDT) In-Reply-To: References: Date: Thu, 18 Oct 2012 18:56:28 +0800 X-Google-Sender-Auth: 9w6HpeHV_Uxd_0csqICz7XBjjDw Message-ID: To: Pierre Joye Cc: PHP Internals , PECL Announce , Dmitry Stogov , Dmitry Stogov Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Please do not call zval_dtor on recursive array From: laruence@php.net (Laruence) On Thu, Oct 18, 2012 at 6:45 PM, Pierre Joye wrote: > hi Dmitry, Laruence! > > On Thu, Oct 18, 2012 at 11:46 AM, Laruence wrote: >> Hey: >> >> recently we found a problem, that is "usage zval_dtor on a recursive >> array while gc enabled" has chance to result a segfault. >> >> a reproduce script could be found here: >> https://github.com/php/php-src/blob/8bd5e15ff7a57791956c4017ee8fb4a8ac0d8d2e/ext/pcre/tests/bug63055.phpt >> >> the preg_match used to call zval_dtor on the third argument. which >> result a segfault, reported at #63055 >> >> the segfault backtrace will looks like: http://pastebin.com/uPWBgrTZ >> >> thanks to dmitry, we got a simple solution, that is: instead of >> directly call to zval_dtor, please use following codes instead: >> " >> zval garbage = *subpats; >> array_init(subpats); >> zval_dtor(&garbage); >> " > Nice catch! > > We could add a macro? As it looks like many will forget to do that :) maybe a seris macro: ZVAL_REPLACE_LONG() ZVAL_REPLACE_STRING{L}() ZVAL_REPLACE_ZVAL() etc; thanks , will do it later, only for trunk I think thanks > > Cheers, > -- > Pierre > > @pierrejoye | http://blog.thepimp.net | http://www.libgd.org -- Laruence Xinchen Hui http://www.laruence.com/