Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19552 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45594 invoked by uid 1010); 10 Oct 2005 16:40:17 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 45579 invoked from network); 10 Oct 2005 16:40:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Oct 2005 16:40:17 -0000 X-Host-Fingerprint: 69.12.155.130 69-12-155-130.dsl.static.sonic.net Linux 2.4/2.6 Received: from ([69.12.155.130:2122] helo=pigeon.alphaweb.net) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 5C/BA-54476-0799A434 for ; Mon, 10 Oct 2005 12:40:17 -0400 Received: from localhost ([127.0.0.1] helo=lighthammer) by pigeon.alphaweb.net with smtp (Exim 4.10) id 1EOzz7-0001tA-00; Mon, 10 Oct 2005 08:54:42 -0700 Message-ID: <001b01c5cdb9$48822620$86660646@lighthammer> To: "David Olsson" Cc: References: <4A.46.54476.C2272434@pb1.pair.com> <002801c5c8fe$b62d2ef0$6d561a44@lighthammer> <8F.35.54476.F96D4434@pb1.pair.com> <002f01c5caa1$da4f1b50$ad6c0646@lighthammer> <434A2B43.7020608@vimio.com> Date: Mon, 10 Oct 2005 09:39:36 -0700 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Subject: Re: zval "passthrough"? From: pollita@php.net ("Sara Golemon") > So that means that all the zval * I store in my map simply point to > invalid memory once the request is completed? Well, that would explain > some of the strange behaviour I have observed (such as string changing > content between requests). > Yep. > The solution to this would be to allocate the > zval struct using pemalloc and allocate memory for the data the zval > (whatever type it is) uses with pemalloc as well? > When you get the zval* in your strore_var_in_map() function it's non-persistent. You need to copy all of its data (and dependent data) into persistent storage when you store it in your map. Then when you take it out of map to return it back to userspace (possibly in another request), you need to copy it again to place it in non-persistent storage. > As far as I can tell, the APC extension doesn't use pemalloc but rather > malloc. Furthermore, pemalloc simply seems to be a macro which uses > malloc to allocate memory. This means that my memory allocations using > c++ new should allocate persistent memory chunks. > That's correct. It's not allocating the persistent memory chunks that's hard, it's duplicating a generic zval (in all the various forms that a zval can take) that's tricky (particularly in the case of IS_OBJECT and IS_RESOURCE). > S the persistent/non-persistent memory issue doesn't explain why my > std::map > simply is empty. The fact that it contain zval pointers pointing to > invalid memory I understand but I don't get why it gets emptied. Any > ideas? > Post the code you have so far. I'm working with a pretty limited pinhole view here.... -Sara