lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


In lstate.c, the following comment exists:

** macros for thread syncronization inside Lua core machine:
** all accesses to the global state and to global objects are
syncronized.
** Because threads can read the stack of other threads
** (when running garbage collection),
** a thread must also syncronize any write-access to its own stack.
** Unsyncronized accesses are allowed only when reading its own stack,
** or when reading immutable fields from global objects
** (such as string values and udata values). 

Exactly what does it mean to "synchronize any write-access to its own
stack"?  I'm seeing a case that may be related to this.  I've seen a few
"random" crashes in my app since I increased the garbage collection
frequency, where one thread is running Lua instructions and making
callbacks to C while the other thread is garbage collecting.

I saw these random crashes more often when I didn't have
luaC_collectgarbage() wrapped in a lua_lock() and lua_unlock().  I
haven't noticed any adverse effects by wrapping the garbage collection,
but the crashes still happen on occasion.

Ideas?  Anyone?

Josh