-
Notifications
You must be signed in to change notification settings - Fork 187
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
File system requests for nonexistent paths may result in invalid userdatum #718
Comments
Have you tested this with Luvit? I was just trying to use this code with Luvit but it seems to work fine, errors with
|
My first assumption here is that this has something to do with walking the handles before running the event loop. |
The I'm also more confused at how you've gotten uv_walk to segfault when this program creates no handles ( |
The SEGFAULT is a red herring; there's an unrelated problem (not apparent from the example) which I've partially solved for the Additionally, the example did SEGFAULT using I'll leave the issue open for now. No need to spend time on this, though. I'll hopefully get back to it soon... (famous last words) |
Regardless of the above, there may be some value in addressing the other points:
I guess the message could be confusing if one doesn't know much about how luv works internally. If it's expected that the request could become invalid while still accessible to the Lua program, maybe a more descriptive error message could be emitted? I rarely use
This is a good idea and indeed one of the oddities I observed is that running the event loop intermittently can change the result. On Windows, I saw that calling
My bad. I tried to reduce a more complex example, but I forgot about things like the unref'd SIGPIPE handler ( Edit: I'll leave the original example as-is even if it doesn't create any handles. The rest will become clearer with more context. |
It seems that opening a handle with a path that doesn't exist can cause crashes when (potentially unrelated) code later tries to access it:
The program is halted with an assertion failure, which is triggered by a somewhat unreliable sanity check in
src/loop.c
:Occasionally, this sanity check fails and the program simply SEGFAULTs when trying to invoke the callback:
The handle itself appears to be active, but its context (
data->ctx
) isNULL
. There were some issues mentioning cleanup and callback interactions; this may be related. Attempting to use the handle inside the callback, withoutuv.walk
, also fails (uv.run()
is implied):The resulting Lua error is technically preventable since the
err
andfd
values indicate a failure, but it could still be slightly confusing:ENOENT: no such file or directory: does-not-exist nil userdata Uncaught Error: bad argument #1 to '?' (Expected uv_req_t)
I encountered this issue while queuing FS requests with some observability code enabled, which required walking all handles. There's no obvious way of guarding against these crashes, so that even a simple typo in a file system path could bring down the entire application.
Tested on Windows and Linux (Ubuntu) using the latest LuaJIT build. This doesn't look like a platform-specific problem, though.
The text was updated successfully, but these errors were encountered: