Skip to content

Segmentation fault: 11 error #14

Closed

Description

@jilieryuyi

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);

Activity

  1. ichiriac commented on Mar 8, 2017

    @ichiriac

    Hi @jilieryuyi,

    I'll take a look at this issue tonight

  2. self-assigned this
    on Mar 8, 2017
  3. added this to the milestone on Mar 8, 2017
  4. jilieryuyi commented on Mar 8, 2017

    @jilieryuyi
    Author

    Has it been fixed? This bug still happen after recompile

  5. ichiriac commented on Mar 8, 2017

    @ichiriac

    Not yet, the night may be long :)

  6. ichiriac commented on Mar 8, 2017

    @ichiriac

    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

  7. jilieryuyi commented on Mar 8, 2017

    @jilieryuyi
    Author

    Just a test ! thank you for your answer !

  8. added 3 commits that reference this issue on Mar 9, 2017
  9. ichiriac commented on Mar 9, 2017

    @ichiriac

    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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions