Bug #77751 [Opn->Fbk]: Writing to SplFileObject in ob_start gives segfault
| From: | requinix@php.net | Date: | Fri, 15 Mar 2019 19:45:50 +0000 |
| Subject: | Bug #77751 [Opn->Fbk]: Writing to SplFileObject in ob_start gives segfault | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-219992@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77751&edit=1
ID: 77751
Updated by: requinix@php.net
Reported by: michael dot mauch at gmx dot de
Summary: Writing to SplFileObject in ob_start gives segfault
-Status: Open
+Status: Feedback
Type: Bug
Package: Output Control
Operating System: Ubuntu 16.04
PHP Version: 7.3.3
Block user comment: N
Private report: N
New Comment:
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php
for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php
for Win32
Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2019-03-15 19:08:23] michael dot mauch at gmx dot de
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 this bug report at https://bugs.php.net/bug.php?id=77751&edit=1