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

Segmentation fault: 11 error #14

Closed
jilieryuyi opened this issue Mar 7, 2017 · 6 comments
Closed

Segmentation fault: 11 error #14

jilieryuyi opened this issue Mar 7, 2017 · 6 comments
Assignees
Milestone

Comments

@jilieryuyi
Copy link

I got an error Segmentation fault: 11

run with code :

$base = event_base_new();
$event = event_new();

event_set($event, 0, EV_TIMEOUT, function() {
echo "function called";
});
event_base_set($event, $base);

event_add($event, 5000000);
event_base_loop($base);

@ichiriac
Copy link

ichiriac commented Mar 8, 2017

Hi @jilieryuyi,

I'll take a look at this issue tonight

@ichiriac ichiriac added the bug label Mar 8, 2017
@ichiriac ichiriac self-assigned this Mar 8, 2017
@ichiriac ichiriac added this to the Stable release on PHP7 milestone Mar 8, 2017
@jilieryuyi
Copy link
Author

Has it been fixed? This bug still happen after recompile

@ichiriac
Copy link

ichiriac commented Mar 8, 2017

Not yet, the night may be long :)

@ichiriac
Copy link

ichiriac commented Mar 8, 2017

Just a question, if you want to use it as a timer, why don't you use event_timer_new instead of event_new :

<?php
  function tick() {
    echo 'tick';
  }

  // create ressources
  $base = event_base_new();
  $event = event_timer_new();

  // configure
  event_timer_set($event, 'tick');
  event_base_set($event, $base);
  event_add($event, 1000);

  // run
  event_base_loop($base, EVLOOP_ONCE);

The segmentation fault comes from the fact that the 500000 is considered as a long and tries to convert it to a ressource (old legacy code).

IMO it would just raise a warning, return false, and I should remove the long argument type in order to be more strict. Need to digg in order to be sure what usecase could be possible for a ressource -> long

Please, tell me if it's OK with the timer functions

@jilieryuyi
Copy link
Author

Just a test ! thank you for your answer !

ichiriac added a commit that referenced this issue Mar 9, 2017
ichiriac added a commit that referenced this issue Mar 9, 2017
@ichiriac
Copy link

ichiriac commented Mar 9, 2017

Hi @jilieryuyi,

It's fixed, could help with snippets like these. You can make PHPT files here : https://github.com/expressif/pecl-event-libevent/tree/master/tests and send me a pull request, it would greatly improve the library stability

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

No branches or pull requests

2 participants