lua-users home
lua-l archive

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


Gé Weijers wrote:

On Apr 2, 2007, at 5:57 PM, Rici Lake wrote:

There is an unrelated issue with the use of the address of a global
static structure in ltable.c. I think that ought to get fixed.


What's the problem here (I assume it's related to 'dummynode')? The address seems to be used only as a marker. That's not any different from using the address of a global variable to create a light user data to be used as a unique key, which seems fairly common.


Precisely.

If you happen to have two different copies of liblua
(typically this happens when a statically-linked module is dynamically-loaded) then the addresses depend on which copy
is active.

In particular, if there are two different copies of ltable.c,
then tables created by one of them are incompatible with the
other one, and resizing a table can result in an attempt to
free() a static pointer.

Of course, you shouldn't have two copies of liblua, but it
happens, and it's easier to compensate for the error than to
detect it; with some implementations of malloc(), the erroneous
free() segfaults immediately, but on others it just corrupts
malloc's internal data structures and the error shows up at
some random future point in time.