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

Use main thread of current Lua state for callbacks, when known #734

Merged
merged 1 commit into from
Nov 15, 2024

Commits on Nov 15, 2024

  1. Use main thread of current Lua state for callbacks, when known

    If the library is opened from a Lua thread (coroutine) that is not the main
    one, the stored L would be to that thread, which may become suspended (by
    calling yield). It is unsafe to call functions on suspended Lua threads, which
    luv does a lot (the stored L is used for callbacks).
    
    The main thread of a Lua state can never yield, so it is always safe to call
    callbacks on.
    
    This commit ensures the main thread is stored in the luv context instead of
    the current thread, when we are able to calculate it (LUA_RIDX_MAINTHREAD was
    added in Lua 5.2, and I have not found a way to determine the main thread in
    Lua 5.1).
    
    This fixes luvit#503
    mwild1 committed Nov 15, 2024
    Configuration menu
    Copy the full SHA
    ba4589c View commit details
    Browse the repository at this point in the history