Bug #72131 [Opn->Fbk]: Calling number_format(null) causes curl to not decode chunks

From: Date: Sat, 30 Apr 2016 05:34:47 +0000
Subject: Bug #72131 [Opn->Fbk]: Calling number_format(null) causes curl to not decode chunks
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200841@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72131&edit=1 ID: 72131 Updated by: pajoye@php.net Reported by: andre at webkr dot de Summary: Calling number_format(null) causes curl to not decode chunks -Status: Open +Status: Feedback Type: Bug Package: Reproducible crash Operating System: Linux PHP Version: 5.5.35 Block user comment: N Private report: N New Comment: number_format(null); is the same than number_format(0); except if strict_types=1 is used. And nothing in the number_format function affects something in the current context or globally. (see http://lxr.php.net/xref/PHP_MASTER/ext/standard/math.c#1275) Only to confirm the issue, the problem disappears if you remove the if ($i >= 2) block altogether right? Previous Comments: ------------------------------------------------------------------------ [2016-04-29 23:05:00] andre at webkr dot de Here's a Dockerfile that reproduces the bug and a little server (in Go) that returns chunked responses: https://github.com/AndreKR/php-bug-72131 ------------------------------------------------------------------------ [2016-04-29 22:46:14] andre at webkr dot de Description: ------------ This bug exists in PHP 5.5.35, PHP 5.6.21 and PHP 7.0.6. When you make repeated curl requests to a server that returns the answer chunked-encoded, those requests start to fail with the error "Problem (2) in the Chunked-Encoded data" as soon as you call number_format(null). Admittedly number_format(null) makes no sense, but it throws no error either. When you call number_format(null) a second time, cURL can decode chunks again, a third time again brings the error, and so on. Test script: --------------- $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost/'); // This URL must return a chunked response curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); for($i = 0 ; $i < 10 ; $i++) { $result = curl_exec($ch); var_dump($result); var_dump(curl_error($ch)); if($i >= 2) { echo "\n" . 'number_format(null) called' . "\n"; number_format(null); } echo "\n"; } Expected result: ---------------- (Created by requesting a URL that does not respond in chunks) string(2) "OK" string(0) "" string(2) "OK" string(0) "" string(2) "OK" string(0) "" number_format(null) called string(2) "OK" string(0) "" number_format(null) called string(2) "OK" string(0) "" number_format(null) called string(2) "OK" string(0) "" number_format(null) called string(2) "OK" string(0) "" number_format(null) called string(2) "OK" string(0) "" number_format(null) called string(2) "OK" string(0) "" number_format(null) called string(2) "OK" string(0) "" number_format(null) called Actual result: -------------- string(2) "OK" string(0) "" string(2) "OK" string(0) "" string(2) "OK" string(0) "" number_format(null) called bool(false) string(39) "Problem (2) in the Chunked-Encoded data" number_format(null) called string(2) "OK" string(0) "" number_format(null) called bool(false) string(39) "Problem (2) in the Chunked-Encoded data" number_format(null) called string(2) "OK" string(0) "" number_format(null) called bool(false) string(39) "Problem (2) in the Chunked-Encoded data" number_format(null) called string(2) "OK" string(0) "" number_format(null) called bool(false) string(39) "Problem (2) in the Chunked-Encoded data" number_format(null) called ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72131&edit=1

« previous php.bugs (#200841) next »