wahern / cqueues

Continuation Queues: Embeddable asynchronous networking, threading, and notification framework for Lua on Unix.
http://25thandclement.com/~william/projects/cqueues.html
MIT License
248 stars 37 forks source link

error thrown from sleep: attempt to call a userdata value #234

Open pspacek opened 4 years ago

pspacek commented 4 years ago

Occasionally I receive mystical errors from cqueues:

error: attempt to call a userdata value stack traceback:
    [C]: in function 'poll'
    /usr/share/lua/5.1/cqueues.lua:62: in function 'sleep'
    /usr/lib/knot-resolver/kres_modules/prometheus.lua:91: in function </usr/lib/knot-resolver/kres_modules/prometheus.lua:39>

This happens asynchronously and I cannot see any explanation in my code, it just calls sleep.

The only wild idea that came to my mind is a problem with premature termination of syscalls but I do not have sufficient knowledge of cqueues and coroutines to dig deeper.

Any ideas what it might be and how to fix that?

daurnimator commented 4 years ago

I'd probably start by printing off the stack just before the lua_pcall?

pspacek commented 4 years ago

Hmm, I do not undestand what you mean. My code is calling .sleep(1) ... do you mean adding a pcall to someplace in cqueues?

daurnimator commented 4 years ago

do you mean adding a pcall to someplace in cqueues?

https://github.com/wahern/cqueues/blob/813664c99c393acbcb007023b195b241a6b90a20/src/cqueues.c#L1638