Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98207 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94562 invoked from network); 5 Feb 2017 14:03:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2017 14:03:52 -0000 Authentication-Results: pb1.pair.com smtp.mail=andrey@andb.name; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=andrey@andb.name; sender-id=pass Received-SPF: pass (pb1.pair.com: domain andb.name designates 185.11.74.146 as permitted sender) X-PHP-List-Original-Sender: andrey@andb.name X-Host-Fingerprint: 185.11.74.146 andb.name Received: from [185.11.74.146] ([185.11.74.146:34168] helo=andb.name) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E2/1E-38491-2C037985 for ; Sun, 05 Feb 2017 09:03:49 -0500 Received: from mail.andb.name (localhost [127.0.0.1]) by andb.name (Postfix) with ESMTPA id 9EDFE301ABA; Sun, 5 Feb 2017 17:03:42 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.10.3 andb.name 9EDFE301ABA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=andb.name; s=mail; t=1486303422; bh=KaeEj1dCwDp3SiZqpghhMQiuqfE8WHtn5M+45i0tN78=; h=Date:From:To:Cc:Subject:From; b=mW10rwKKrreNP6eRRFIzuL81gvp/dyYIwYM8B/ll+wS1q9IBcNupKZ3hzGqs5KxL9 GYrPf4zPJ/G1PBPQFfkr5c5auRPdzCKs8HlBrvc1t2xII/rQV0GlL3HJlPBzk8gCQh PXvfzjq3wXVLE0r0TacRiQjhGKQWQRK0munOSdNc= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sun, 05 Feb 2017 21:03:42 +0700 To: internals Cc: laruence@php.net Message-ID: <48a7eb6950ea9a1f512937f138dd5fb9@andb.name> X-Sender: andrey@andb.name User-Agent: Roundcube Webmail/1.3-git Subject: [PHP-DEV] Need help with strange and random bug From: andrey@andb.name (Andrey E Baranov) Hi all, I have problem, debug is not yet finished, and for now do not can reproduce, problem occurs only in production (after migrate to PHP7). perhaps someone else can help :) PHP 7.0.13 (Ubuntu 16.04 package repository), php-fpm For simplify: ``` ... Log::debug('1:' . print_r($video, true)); Log::debug('2:' . json_encode($video) . ' json_last_error: ' . json_last_error() . ' json_last_error_msg: ' . json_last_error_msg()); $video['delivery'] = [2]; // after this line: serialize and json_encode do not work as expected Log::debug('3:' . print_r($video, true)); Log::debug('4:' . serialize($video)); Log::debug('5:' . json_encode($video) . ' json_last_error: ' . json_last_error() . ' json_last_error_msg: ' . json_last_error_msg()); ... ``` log with bug: ``` DEBUG: 1:Array ( [mimes] => Array ( [0] => video/mp4 ) [linearity] => 1 [minduration] => 5 [maxduration] => 60 [protocols] => Array ( [0] => 2 [1] => 3 ) [w] => 818 [h] => 460 [minbitrate] => 100 [maxbitrate] => 1200 ) DEBUG: 2: {"mimes":["video/mp4"],"linearity":1,"minduration":5,"maxduration":60,"protocols":[2,3],"w":818,"h":460,"minbitrate":100,"maxbitrate":1200} DEBUG: 3:Array ( [mimes] => Array ( [0] => video/mp4 ) [linearity] => 1 [minduration] => 5 [maxduration] => 60 [protocols] => Array ( [0] => 2 [1] => 3 ) [w] => 818 [h] => 460 [minbitrate] => 100 [maxbitrate] => 1200 [delivery] => Array ( [0] => 2 ) ) DEBUG: 4:a:10:{s:5:"mimes";a:1:{i:0;s:9:"video/mp4";}s:9:"linearity";i:1;s:11:"minduration";i:5;s:11:"maxduration";i:60;s:9:"protocols";a:2:{i:0;i:2;i:1;i:3;}s:1:"w";i:818;s:1:"h";i:460;s:10:"minbitrate";i:100;s:10:"maxbitrate";i:1200;s:8:"delivery";N;} DEBUG: 5: json_last_error: 6 json_last_error_msg: Recursion detected ``` - 4: `serialize($video)` - `"delivery";N;` - it is mean that `delivery` is Null - that is not true - 5: `json_encode($video)` - Recursion detected Problem occurs in random period after start fpm process (after 10..30 min), and remains constant until restart fpm Same problem as I see in http://stackoverflow.com/questions/37456845/what-does-json-error-recursion-mean-from-json-encode After deep analyze: php_json_encode_array: ``` ``` if (myht && ZEND_HASH_GET_APPLY_COUNT(myht) > 1) { JSON_G(error_code) = PHP_JSON_ERROR_RECURSION; smart_str_appendl(buf, "null", 4); return; } ``` serialize: ``` if (... || (Z_TYPE_P(data) == IS_ARRAY && Z_ARRVAL_P(data)->u.v.nApplyCount > 1) ) { smart_str_appendl(buf, "N;", 2); ... ``` so looks like problem in `HashTable.v.nApplyCount` Also I am find commit - https://github.com/php/php-src/commit/d26ca894020bc28eb55b153fac5548374d5ce16d In this commit added ``` target->u.flags = (source->u.flags & ~(...|ZEND_HASH_APPLY_COUNT_MASK))... ``` But not added to case if `if (GC_FLAGS(source) & IS_ARRAY_IMMUTABLE)` - maybe need fix in this place? :) I guess that the problem in immutable arrays. I do not have experience with PHP-SRC - and I could be wrong thanks!