Bug #77751 [NEW]: Writing to SplFileObject in ob_start gives segfault
| From: | michael dot mauch at gmx dot de | Date: | Fri, 15 Mar 2019 19:08:23 +0000 |
| Subject: | Bug #77751 [NEW]: Writing to SplFileObject in ob_start gives segfault | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-219989@lists.php.net to get a copy of this message | ||
From: michael dot mauch at gmx dot de
Operating system: Ubuntu 16.04
PHP version: 7.3.3
Package: Output Control
Bug Type: Bug
Bug description:Writing to SplFileObject in ob_start gives segfault
Description:
------------
I'm using a function like below to redirect all output to a log file in
PHP CLI scripts.
It works until PHP 7.1, but crashes with SIGSEGV in 7.2 and 7.3. If I
use old fopen() instead of SplFileObject, it also works with 7.2 and
7.3.
Oracle Linux 7.x at work, Ubuntu 16.04 at home, or even in docker with
the official images.
Test script:
---------------
<?php
$logfilename = "/tmp/crash.log";
$logfile = new SplFileObject($logfilename, "w");
ob_start(function ($buffer) use ($logfile) {
$logfile->fwrite($buffer);
$logfile->fflush();
return "";
});
echo "hmm\n";
Expected result:
----------------
# Like with PHP 7.1:
% docker run -it --rm -v "$PWD":/tmp -w /tmp php:7.1-cli /bin/bash -c
'ulimit -c unlimited; php -v; php ./crash.php && echo ok'
PHP 7.1.27 (cli) (built: Mar 9 2019 02:51:22) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
ok
Actual result:
--------------
# But with PHP 7.3:
% docker run -it --rm -v "$PWD":/tmp -w /tmp php:cli /bin/bash -c
'ulimit -c unlimited; php -v; php ./crash.php && echo ok'
PHP 7.3.3 (cli) (built: Mar 9 2019 00:27:53) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.3, Copyright (c) 1998-2018 Zend Technologies
/bin/bash: line 1: 7 Segmentation fault (core dumped) php
./crash.php
--
Edit bug report at https://bugs.php.net/bug.php?id=77751&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77751&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77751&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77751&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77751&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77751&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77751&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77751&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77751&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77751&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77751&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77751&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77751&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77751&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77751&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77751&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77751&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77751&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77751&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77751&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77751&r=mysqlcfg