Skip to content

Why does mlua hold a lua state lock across an entire resume call #617

Answered by khvzak
cheesycod asked this question in Q&A
Discussion options

You must be logged in to vote

The main purpose of the lock is to protect Lua VM. If release the lock before Thread::resume call, then another thread waiting for the lock will acquire it, get access to the VM and can execute any operations. Such scenario is not supported by Lua and will cause UB.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@cheesycod
Comment options

@cheesycod
Comment options

@khvzak
Comment options

Answer selected by cheesycod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #616 on July 20, 2025 10:22.