Skip to content

Hitting crash with: event_del_nolock_: noting a del on a non-setup event #1283

@aniruddha-a

Description

@aniruddha-a

Hello,

Some background:
I have wrapped my libevent-2.1.8-stable based C code to use with Python, and I use this with the python-libevent module.
I have used it with many older versions of python, never had a problem. Now, when I tried porting to Python3.8
I hit a crash at event_add() (the event_base is created and maintained from python-libevent and my module does create
and add events).

From valgrind, I could see that there were some memory/ownership issues, so I made both
my module and python-libevent use python's memory allocators (thread-safe) with event_set_mem_functions.
After that, the event_add() works ; but on a timer-event dispatch, I see the crash at event_del_nolock_ !

[debug] event_add: event: 0x13ef960 (fd 6), EV_READ    call 0x7fd60de5a707
[debug] Epoll ADD(1) on fd 6 okay. Old events were 0; read change was 1 (add); write change was 0 (none); close change was 0 (none)
[debug] event_add: event: 0x1487ea0 (fd -1),    EV_TIMEOUT call 0x7fd60d5a96f6
[debug] event_add: event 0x1487ea0, timeout in 2 seconds 0 useconds, call 0x7fd60d5a96f6
[debug] timeout_next: event: 0x1487ea0, in 2 seconds, 0 useconds
[debug] epoll_dispatch: epoll_wait reports 0
[debug] timeout_next: event: 0x1487ea0, in 0 seconds, 135 useconds
[debug] epoll_dispatch: epoll_wait reports 0
[debug] event_del: 0x1487ea0 (fd -1), callback 0x7fd60d5a96f6
[err] event_del_nolock_: noting a del on a non-setup event 0x1487ea0 (events: 0x0, fd: -1, flags: 0x80)
Aborted (core dumped)

I have enabled pthreads and set the memory functions at the start of both modules (as explained in the documentation).
i.e., both the modules have, at start:

    event_set_mem_functions(PyMem_RawMalloc, PyMem_RawRealloc, PyMem_RawFree);
    evthread_use_pthreads();
    evthread_enable_lock_debugging();
    event_enable_debug_mode();
    event_enable_debug_logging(EVENT_DBG_ALL);

When run with helgrind, I see :

==2331== Process terminating with default action of signal 6 (SIGABRT): dumping core
==2331==    at 0x5C95E87: raise (raise.c:51)
==2331==    by 0x5C977F0: abort (abort.c:79)
==2331==    by 0x6882389: event_exit (log.c:105)
==2331==    by 0x68827D8: event_errx (log.c:162)
==2331==    by 0x68758DE: event_del_nolock_ (event.c:2845)
==2331==    by 0x68766FD: timeout_process (event.c:3147)
==2331==    by 0x6872520: event_base_loop (event.c:1960)
==2331==    by 0x685A35D: pybase_loop (pybase.c:159)
...
==2331== Thread #1: Exiting thread still holds 2 locks

Locks at exit should not be a concern (?)
This is not giving much clues! I am not sure if I have to chase memory or locks or threads here ! :-/
Any help, pointers to debug further, much appreciated.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions