Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71251 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 46889 invoked from network); 18 Jan 2014 20:01:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jan 2014 20:01:55 -0000 Authentication-Results: pb1.pair.com smtp.mail=cornelius.howl@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=cornelius.howl@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.181 as permitted sender) X-PHP-List-Original-Sender: cornelius.howl@gmail.com X-Host-Fingerprint: 209.85.223.181 mail-ie0-f181.google.com Received: from [209.85.223.181] ([209.85.223.181:58886] helo=mail-ie0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 91/00-46720-3BDDAD25 for ; Sat, 18 Jan 2014 15:01:55 -0500 Received: by mail-ie0-f181.google.com with SMTP id tq11so4715814ieb.26 for ; Sat, 18 Jan 2014 12:01:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=L/aD8liBH+V6xAZvsOVFMXWybOs+5XMmzbGhaMxOABg=; b=FbwaXr15WfZm20X7YbKSXJZ/8ykXLBMe5a+GMsNbz/cuZGmoK1IP7JcfNIAA9aHO85 fuRGbtOPZmLf8hcs9+eexC/fdNdUxxcouM8UTy1mz3OSbYomNDZCAf0i3+EEdXid9kL8 MRgVuPUwW+G4J2iLK6Mm6OFcCNMDIGsNMznx3Dg5YiKrCUTcU09y0LHiyak6XR6xgQqI DxforN89xYOmmzwg6Y8A/F5GfuNz22qQOMmhxYWKauUUDDi209xNx1nHaxBg3LQxTxxg It4ZH31aWeSr8dua7cgpfqq8jGoD6bJPzEzEkqfsM2qnaNK5HHJO5frJRb+h8mAB+7P+ QaTw== MIME-Version: 1.0 X-Received: by 10.43.127.200 with SMTP id hb8mr55999icc.80.1390075313145; Sat, 18 Jan 2014 12:01:53 -0800 (PST) Received: by 10.64.6.4 with HTTP; Sat, 18 Jan 2014 12:01:53 -0800 (PST) In-Reply-To: References: Date: Sun, 19 Jan 2014 04:01:53 +0800 Message-ID: To: Daniel Lowrey Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11c214de404ce304f044213b Subject: Re: How to create Persistent zval? From: cornelius.howl@gmail.com (Lin Yo-An) --001a11c214de404ce304f044213b Content-Type: text/plain; charset=Big5 Content-Transfer-Encoding: quoted-printable By the way, Is this the reason of date ext always check the global HashTable and re-initialize the tzdata in every request? Lin Yo-An =A9=F3 2014=A6~1=A4=EB19=A4=E9=ACP=B4= =C1=A4=E9=BCg=B9D=A1G > > > Daniel Lowrey 'rdlowrey@php.net');>> =A9=F3 2014=A6~1=A4=EB19=A4=E9=ACP=B4=C1=A4=E9=BCg= =B9D=A1G > >> >> Hello, >> >> >> >> I am trying to store a zval object into the persistent list in zend V= M. >> >> (Using EG(persistent_list) and zend_rscd_list_entry) >> >> >> >> Which works fine if I store/fetch the zval in the same request contex= t. >> >> >> >> But it seems that zend engine cleans up the zval object after the >> request, >> >> when the next request comes, the fetched list entry points to a freed >> zval >> >> address and it makes php segmentationfault. I guess zval is allocated >> by >> >> emalloc, so I cant keep it cross requests? >> >> > For persistent alloc, you should use pemalloc() , which is just a >> > wrapper leading to libc's malloc. >> > If you use emalloc() , the Zend Memory Manager will free the storage >> > at the end of the request, thus leading to use-after-free crash if you >> > reuse your pointer on a next request. >> >> --- Disclaimer --- >> I'm passing this along; Joe is having technical difficulties and asked f= or >> help sending this to the list. I provide no warranties or refunds ;) >> --- >> >> All zvals passed into the engine must be allocated by the mm, you cannot >> pemalloc anything and pass it into the engine safely. >> >> You don't want to store a persistent zval, you want to store a persisten= t >> resource entry, which should be allocated with pemalloc(size, 1) >> >> The reason for this is when cleaning up, the engine has no means by whic= h >> to tell if a zval has been pemalloc or emalloc'd, zval_ptr_dtor works th= e >> same for everything. > > > > Thank you so much! That is what i was guessing.. - ref cnt and pemalloc > does not work for persistent zval. > > And zend engine cleans up zvals at the end of request no matter the ref > cnt is? > > so zval is not persistent, then is HashTable persistent? > > It's because I need to store a zval object which has several properties. > Is there a way to do make the object persistent? Or do i need to seriali= ze > it just like apc? > > > >> Cheers >> Joe >> > > > -- > Best Regards, > > Yo-An Lin > > --=20 Sent from Gmail Mobile --001a11c214de404ce304f044213b--