-
Notifications
You must be signed in to change notification settings - Fork 16
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
supplied resource is not a valid stream resource #11
Comments
Reply please , I open this Issue on Jan 9 and I need to solve the problem , Help please Please see walkor/workerman#130 I test it in php5.6 and libevent , it works well but in php7 and libevent , I have this error
|
@ichiriac Help me |
Hi @sm2017, Sorry, I've not saw your issue before today. I think the problem comes with this statement : Running this statement : This will run into the code (and it's okay) : Not sure why (bad refcount maybe), but also seems to trigger this code : I need to check this in debug mode but for me, when you call the del function, followed by event_del statement, it seems that the object after unset does not have any more references to him. The garbage collector passes, and kills the object (line 153 on libevent.c), and the ressource is also closed. After investigations, this line is changes to be compliant with PHP7 (zend_list_delete to zend_list_close)
So when the event is destroyed (no more references to him), the connection is closed, that explains your warnings. One solution could be to revert back to Sorry but I have no time to work again on libevent, maybe in few month I will be back again on this but for now I'm stuck on other projects.
|
@ichiriac , I need to fix the bug , Please fix it ASAP and help me |
ok @sm2017, ping me back in 1 month if it's not moving. I'll update this issue when it will be fixed. |
Thanks a lot , I will check this page periodically |
@ichiriac i have this issue too but i forget that if you solve its nice help for me |
@ichiriac Update me please |
Hi @sm2017, I'll take a look at this tonight |
Thanks a lot 😆 👍 |
I'll continue tomorrow, I've did not succeed to force the GC with a small code |
I hope , the following references helps stream_socket_client - STREAM_CLIENT_ASYNC_CONNECThttps://github.com/walkor/Workerman/blob/master/Connection/AsyncTcpConnection.php#L171-L172 EV_WRITEhttps://github.com/walkor/Workerman/blob/master/Connection/AsyncTcpConnection.php#L186 supplied resource is not a valid stream resourcehttps://github.com/walkor/Workerman/blob/master/Connection/AsyncTcpConnection.php#L263 fd argument must be either valid PHP stream or valid PHP socket resourcehttps://github.com/walkor/Workerman/blob/master//Events/Libevent.php#L105 |
Hi @sm2017, The issue should be fixed, can you try by rebuilding from sources or do you need windows binaries ? I can't reproduce the bug directly as in PHP7 it's not easy to trigger the GC, so I need you to test and tell me if it's OK. Then I'll take tome time to find out a way to trigger properly the garbage collector, in order to cover this ticket with tests |
I install libevent @05900f3b8d70deb424b3193a4eb850062f146638 , but same result , I have Read http://php.net/manual/en/function.gc-collect-cycles.php maybe helps |
See #16 I found that the problem is Before event_free the $fd is resource of type (stream) and after resource of type (Unknown) so in next lines we have |
ouch : https://github.com/expressif/pecl-event-libevent/blob/master/libevent.c#L605 - explicitely closes the list / was not the case before the migration : https://github.com/php/pecl-event-libevent/blob/master/libevent.c#L605 |
I install again libevent extension and run test script the result is <?php
/* poll STDIN using basic API */
function foo($fd, $events, $arg)
{
static $i;
$i++;
if ($i == 10) {
event_base_loopexit($arg[1]);
}
var_dump(fread($fd, 1));
}
$base = event_base_new();
$fd = fopen('https://raw.githubusercontent.com/expressif/pecl-event-libevent/master/tests/input.txt', 'r');
// first event reader
$ev1 = event_new();
var_dump(event_set($ev1, $fd, EV_READ | EV_PERSIST, "foo", array($ev1, $base)));
var_dump(event_base_set($ev1, $base));
var_dump(event_add($ev1));
var_dump(event_base_loop($base, EVLOOP_ONCE));
var_dump(event_del($ev1));
var_dump($fd);
event_free($ev1);
unset($ev1);
var_dump($fd);
// second event reader
$ev2 = event_new();
var_dump(event_set($ev2, $fd, EV_READ | EV_PERSIST, "foo", array($ev2, $base)));
var_dump(event_base_set($ev2, $base));
var_dump(event_add($ev2));
var_dump(event_base_loop($base, EVLOOP_ONCE));
var_dump(event_del($ev2));
unset($ev2);
?>
|
@sm2017, I'm looking at it, I'll tell you when it's fixed so you can test |
@ichiriac Ok just I found another issue See https://github.com/walkor/Workerman/blob/master/Events/Libevent.php#L84 , the 2th argument of |
@sm2017, this bug is now fixed, travis passed, waiting your confirmation. For the other bug can you open a new issue and send a PR with a phpt to reproduce the error, check the output with php5 in order to get the output for the expected section. |
I run test script and it works , but in main project I have issue let me find the problem |
I think we have In this line https://github.com/walkor/Workerman/blob/152756a04f95645217d159f5a496077de0be65cd/Worker.php#L1022 we have |
I want to create a phpt file for Segmentation fault bug , But I cannot , Can you help me? I know the problem is Please do following
The code running in following order https://github.com/walkor/GatewayWorker/blob/master/src/Gateway.php#L819 The problem is https://github.com/walkor/Workerman/blob/master/Events/Libevent.php#L113 I don't know why in this line script will be terminated and send SIGSEGV to parent process https://github.com/walkor/Workerman/blob/master/Worker.php#L1022 But in PHP 5.6 and libevent it workes well |
See walkor/workerman#130
The text was updated successfully, but these errors were encountered: