Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93364 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58039 invoked from network); 17 May 2016 01:44:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 May 2016 01:44:29 -0000 Authentication-Results: pb1.pair.com smtp.mail=xinchen.h@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=laruence@php.net; sender-id=unknown Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.223.181 as permitted sender) X-PHP-List-Original-Sender: xinchen.h@zend.com X-Host-Fingerprint: 209.85.223.181 mail-io0-f181.google.com Received: from [209.85.223.181] ([209.85.223.181:33339] helo=mail-io0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4C/00-57067-9777A375 for ; Mon, 16 May 2016 21:44:25 -0400 Received: by mail-io0-f181.google.com with SMTP id f89so5778154ioi.0 for ; Mon, 16 May 2016 18:44:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=u6ApoZLUvjEporMmbh15gUXdkiqeSraRF+0M+fRCr1U=; b=YbETeXFic2xh+vXRZbRaZhwiv7ejOawEBXMTEo1shpgP3VWRVh02tHwqCPI6iJ4yOL +C/Btkj77mqp18IoJj9ZeXjc+4j+f11MoiCbyrLcF5sWfU/vcSffpbs3SMRCqw+l8rB1 CldWcrP9QKWsFC0sNegGv/aVUae19mMP5eBPUeE+UxmZy4QW+5KLLE1J+FrLzqDW72bR FjK8JBP036ADoVrUqSwNP8QHgEHF5aYL0w3m7Xs7re4L01MB+ADA5J4eWElZNDt2PCTt KvAL9Xf4Y65lnxrzHqPBZFk1Sl/rpibLhvPqtzF/i9plk2prbO4NAk8H93eTfHPlCdMY ayJQ== X-Gm-Message-State: AOPr4FXo+Qvaex0ifQzhWpiPEo4iVqmo2WVwZe0tcdO+PkZbriPOg+EgwB2TdgJIsdapbOQ8 X-Received: by 10.107.130.160 with SMTP id m32mr24745464ioi.137.1463449463130; Mon, 16 May 2016 18:44:23 -0700 (PDT) Received: from mail-io0-f178.google.com (mail-io0-f178.google.com. [209.85.223.178]) by smtp.gmail.com with ESMTPSA id qb7sm6405897igb.17.2016.05.16.18.44.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 May 2016 18:44:22 -0700 (PDT) Received: by mail-io0-f178.google.com with SMTP id f89so5777606ioi.0 for ; Mon, 16 May 2016 18:44:21 -0700 (PDT) X-Received: by 10.36.47.136 with SMTP id j130mr10787790itj.48.1463449461717; Mon, 16 May 2016 18:44:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.103.67 with HTTP; Mon, 16 May 2016 18:44:02 -0700 (PDT) In-Reply-To: References: Date: Tue, 17 May 2016 09:44:02 +0800 X-Gmail-Original-Message-ID: Message-ID: To: Adam Baratz Cc: "internals@lists.php.net" , Peter LeBrun Content-Type: multipart/alternative; boundary=001a114417fe500a1b0532ffe163 Subject: Re: [PHP-DEV] reused hash tables in large data structures in PHP7 From: laruence@php.net (Xinchen Hui) --001a114417fe500a1b0532ffe163 Content-Type: text/plain; charset=UTF-8 Hey: On Tue, May 17, 2016 at 6:00 AM, Adam Baratz wrote: > Hi, > > I've encountered a hard-to-consistently-reproduce issue with HashTable > zvals. I have code that will generate big nested \stdClass structures for > JSON encoding. It does so using classes that have methods that generate > those fields. For example, you could have a class like this: > > class Block { > public function css_classes() { > return ['x', 'y', 'z']; > } > } > > Other code would translate it into a value that would var_dump() as this: > > object(stdClass)#1 (1) { > ["css_classes"]=> > array(3) { > [0]=> > string(1) "x" > [1]=> > string(1) "y" > [2]=> > string(1) "z" > } > } > > The template data could include multiple instances of Block. As in, a > \stdClass could be generated with multiple copies of that array content. > That data could get sent to json_encode(), which > uses ZEND_HASH_APPLY_PROTECTION/etc. to avoid recursion. I've seen > situations where that array of strings triggers that recursion check. But > the array might be stored in shared memory(immutable array), in this case, you should not edit the apply count , you should check it, like what json does: https://github.com/php/php-src/blob/master/ext/json/json_encoder.c#L156 thanks it's not always, and a php-fpm restart can make it go away. > > Can anyone think of why this might happen? > > Thanks, > Adam > -- Xinchen Hui @Laruence http://www.laruence.com/ --001a114417fe500a1b0532ffe163--