lua-users home
lua-l archive

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


I've just run into a tricky problem with C++ that I'm not quite sure
how to fully diagnose in a Lua module.  This is on OSX, which may
matter.  Essentially I have a lua module written in C++.  In one of my
classes bound as userdata I have a static std::map defined as follows

class A{
 map<int, A*> allocated;
};

In ~A(), I remove the ref to the object from the map if it's in there.
 Now, when I do a lua_close(L), I get an invalid access crash which I
believe is due to the allocated map being destructed somehow before
the all of the A instances have been finalized.  This seemed a bit odd
to me, but I was able to get rid of the crashes by moving allocated to
be a map<int, A*> pointer instead of a full object.  Wierd.  Has
anyone ever seen this before or have an potential explanation?

thanks,
wes