Well, I found the bug, and it was my fault. I'm rather embarrassed, but I found that the bug was in one of my lua_CFunction responses, I had a single method that was accidentally returning the userdata right at the time the proxy __gc had been called, and the handler was assigning it a new proxy key - thus causing a later gc to hit that userdata a 2nd time
Please kindly disregard this bug report now 🙂
From: Roberto Ierusalimschy <firstname.lastname@example.org>
Sent: Friday, April 24, 2020 8:03 PM
To: Lua mailing list <email@example.com>
Subject: Re: lua 5.4 calls __gc twice, sometimes
> > - Does the bug happen in both modes (generational and incremental)?
> I have left the gc in its default mode, which I believe is inc mode. I have tested with: lua_gc(_state, LUA_GCGEN); and the bug still persists
The default mode in 5.4 is generational. You might change it to incremental
to check that.
One more question: can you be sure the __gc of a table is being called
twice? For what I saw in your code (the first version you sent), the
problem of destroying the same userdata twice could be caused by
some bug in the weak table, if it returned the same userdata for
two different tables. That is, when cleaning the weak table from a
deleted key, it might get corrupted and then could return a wrong
value in a future query.
Again, many thanks,
lua-l mailing list -- firstname.lastname@example.org
To unsubscribe send an email to email@example.com
_______________________________________________ lua-l mailing list -- firstname.lastname@example.org To unsubscribe send an email to email@example.com