Skip to content

Instantly share code, notes, and snippets.

@ramsey
Created October 16, 2017 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramsey/3ebe9ecae9973ba05ba9c5463c099434 to your computer and use it in GitHub Desktop.
Save ramsey/3ebe9ecae9973ba05ba9c5463c099434 to your computer and use it in GitHub Desktop.
Segfault when running built-in PHP web server
<?php
class Foo
{
public function execute($log)
{
file_put_contents($log, "this is a log\n", FILE_APPEND);
}
}
(new Foo())->execute('./mylog.txt');
$ php foo.php
$ cat mylog.txt
this is a log
$ php -S localhost:8000
PHP 7.1.3 Development Server started at Mon Oct 16 17:07:16 2017
Listening on http://localhost:8000
Document root is /home/ramsey/foo
Press Ctrl-C to quit.
[Mon Oct 16 17:07:38 2017] ::1:56424 [200]: /foo.php
[1] 53968 segmentation fault php -S localhost:8000
@jstanden
Copy link

For reference, I don't get a segfault with the script using PHP 7.1.8 on macOS 10.12.6 (compiled from Homebrew).

$ php -S localhost:9090
PHP 7.1.8 Development Server started at Mon Oct 16 16:02:36 2017
Listening on http://localhost:9090
Document root is /Users/jeff/Projects/gists/php
Press Ctrl-C to quit.
[Mon Oct 16 16:02:47 2017] ::1:60583 [200]: /seg.php
$ cat mylog.txt 
this is a log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment