[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Multiple Lua Threads, __gc crash accessing "dead" thread
- From: Francisco Olarte <folarte@...>
- Date: Wed, 13 Sep 2017 18:51:13 +0200
On Wed, Sep 13, 2017 at 6:09 PM, ThePhD <jm3689@columbia.edu> wrote:
> Francisco: Thank you for the suggestion. Unfortunately, I don't have that
> choice. For C code I can make that change, but my example was a stripping
> down of some C++ code. The thing that calls "co_test_destroy" is really a
> C++ destructor, and that destructor can't receive extra parameters. So while
> I know I can fix it if it was just plain C code, it seems like I am more or
> less stuck in the C++ world.
Well, that destructor must have been called from the collectgarbage
loop in the interpreter, so you can always store the passed state
somewhere.
Another simple stuff is to just stuff the pointer to the main state in
the registry, using a lightuserdata as a key. We do this with a couple
of functions, using the getter function address as a lightuserdata as
a key, and works like a charm.
FOS