Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71249 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42969 invoked from network); 18 Jan 2014 19:19:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jan 2014 19:19:37 -0000 Authentication-Results: pb1.pair.com smtp.mail=rdlowrey@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rdlowrey@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.180 as permitted sender) X-PHP-List-Original-Sender: rdlowrey@gmail.com X-Host-Fingerprint: 209.85.213.180 mail-ig0-f180.google.com Received: from [209.85.213.180] ([209.85.213.180:45914] helo=mail-ig0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D1/21-36499-8C3DAD25 for ; Sat, 18 Jan 2014 14:19:37 -0500 Received: by mail-ig0-f180.google.com with SMTP id m12so4526344iga.1 for ; Sat, 18 Jan 2014 11:19:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=/D2QsJQGIXzJfipXkH93ptAZQSBbDU0CDcMmbQsRBbg=; b=ECcyOOY0B275eqvaV43lV3pixFNcw+2QsG3bvyiPbQSnPXXvQkASoE/cUtBL4dpJu9 fnM2yA2bKI3oigKKgLQ5vJZN1gXAxqSIJ7xINlv6N3La2PeLTx1DJOk6WTnx6gTKxTM2 c4QoEPs59czt6rPZvolIkDOibgc/EVqzt198aNzU1p0vfRHOsmJ1OnskHEbLq+wB9R3J xy+jnJoXvm8OLpwWLu40io1T+TFttAYObDZCGC32YxVIme5cTfGB/i+QPc/FomQT2JG9 go1KoDff2I4k+QraGczutGHCSKNPYt5lc3gpnk4uaNeM68+KKtWRYR8ytpsF71/92sju RI3w== MIME-Version: 1.0 X-Received: by 10.43.49.1 with SMTP id uy1mr2391121icb.48.1390072774137; Sat, 18 Jan 2014 11:19:34 -0800 (PST) Sender: rdlowrey@gmail.com Received: by 10.50.29.140 with HTTP; Sat, 18 Jan 2014 11:19:34 -0800 (PST) Date: Sat, 18 Jan 2014 14:19:34 -0500 X-Google-Sender-Auth: eBxgS4YmmwJGoP43_GyjPVEFICo Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=bcaec529a023ea1e8a04f04389d6 Subject: Re: Fwd: How to create Persistent zval? From: rdlowrey@php.net (Daniel Lowrey) --bcaec529a023ea1e8a04f04389d6 Content-Type: text/plain; charset=ISO-8859-1 >> Hello, >> >> I am trying to store a zval object into the persistent list in zend VM. >> (Using EG(persistent_list) and zend_rscd_list_entry) >> >> Which works fine if I store/fetch the zval in the same request context. >> >> 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 for 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 persistent resource entry, which should be allocated with pemalloc(size, 1) The reason for this is when cleaning up, the engine has no means by which to tell if a zval has been pemalloc or emalloc'd, zval_ptr_dtor works the same for everything. Cheers Joe --bcaec529a023ea1e8a04f04389d6--