Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault while spawning a new process with uv_spawn on PHP 5.5.9 #56

Open
gplanchat opened this issue Aug 4, 2014 · 4 comments
Open

Comments

@gplanchat
Copy link

Hello,

The following code produces a segmentation fault on Ubuntu 14.04 LTS with kernel version 3.13.0 and PHP 5.5.9 :

<?php

$ioRead = uv_stdio_new(null, Uv::CREATE_PIPE | Uv::INHERIT_STREAM);
$ioWrite = uv_stdio_new(null, Uv::CREATE_PIPE | Uv::INHERIT_STREAM);
$ioError = uv_stdio_new(null, Uv::CREATE_PIPE | Uv::INHERIT_STREAM);

$loop = uv_default_loop();
$command = 'ls';
$args = [];
$stdio = [
    0 => $ioRead,
    1 => $ioWrite,
    2 => $ioError
];
$cwd = getcwd();
$env = [];
$callback = function() {
    var_dump(func_get_args());
};
$flags = 0;
$options = [];

$process = uv_spawn($loop, $command, $args, $stdio, $cwd, $env, $callback, $flags, $options);

uv_run($loop);
PHP 5.5.9-1ubuntu4.3 (cli) (built: Jul  7 2014 16:36:58) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
uv
PHP libuv Extension

libuv Support => enabled
Version => 0.0.2
libuv Version => 0.10
http-parser Version => 2.2
@steverhoades
Copy link

Anyway you can see if this is fixed with #59 ? I was able to reproduce and fix a uv_spawn related issue with PHP 5.6.

@steverhoades
Copy link

Can confirm this still segfaults with #59.

@steverhoades
Copy link

@gplanchat I have updated the code to throw warnings when a pipe handle is not passed to uv_stdio_new. It appears the correct usage should be:

$ioReadPipe = uv_pipe_init($loop, true);
$ioWritePipe = uv_pipe_init($loop, true);
$ioErrorPipe = uv_pipe_init($loop, true);

$ioRead = uv_stdio_new($ioReadPipe, Uv::CREATE_PIPE | Uv::INHERIT_STREAM);
$ioWrite = uv_stdio_new($ioWritePipe, Uv::CREATE_PIPE | Uv::INHERIT_STREAM);
$ioError = uv_stdio_new($ioErrorPipe, Uv::CREATE_PIPE | Uv::INHERIT_STREAM);

Am i missing something here?

steverhoades added a commit to steverhoades/php-uv that referenced this issue Nov 14, 2014
…ainfiles or php related streams resolving a SIGABRT as epoll doesn't support those stream types
@gplanchat
Copy link
Author

It would say yes, it is the logical path. It seems that you are trying to spawn a new process, but for the use of uv_spawn, isn't the pipes array created by the API?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants