[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: C++ and static deallocators in Lua cause crash
- From: "Wesley Smith" <wesley.hoke@...>
- Date: Sun, 30 Dec 2007 08:25:55 -0600
On Dec 30, 2007 6:29 AM, Wim Couwenberg <firstname.lastname@example.org> wrote:
> does this happen at process exit? In other words, is the lua_close(L)
> triggered by some destructor of a global object? If so, you have to
> be careful about the order in which global objects are destructed.
> (I ask because you suspect that a static member gets destructed.)
Yes, this happens within a Cocoa app when I quit. I have a app-wide
object whose destructor calls lua_close(L); From your post I now
realize that the static map in the module was having its destructor
called before the app-wide singleton holding the Lua state. I wasn't
able to find any good references on the order of static destructors.
Do you happen to have any? My guess is that the destructors are being
called in reverse order, which makes sense but causes havoc with my
current design. I can however grab notifications from Cocoa about
various states in the app closing procedure to close down Lua before
any static destructors are called. I hadn't thought about the need to
do this before, so thanks for the insight.