lua-users home
lua-l archive

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


Hello All,

JC> So, unless I'm mistaken, this a bug of your code and a feature of lua ;-)

And so it is!

It is bug in my code!

Because this is no way in lua to create/set local variables for
threads from the C
side I created a 'hack' that allows to do so. It works in such a way:

I have a list of variables that must be added as locals to this
particular script, and before _compilation_(I store all scripts
compiled) I modify script's text adding in the beginning lines 'local
varname = _varname'. Then before _starting_ this script I set global
vars '_varname' to pass values that must be set as locals to my
script. And so as You see my objects aren't Gc'ed before next script
overwrites global vars '_varname'.

I found this bug only when wrote a small program that emulates my
'threads vs. gc' situation but without tricks with locals. For my
surprise It worked as predicted: everything was GC'ed when i set
thread var to nil. So a minute of thinking and bug was found.

Thanks All for help!
-- 
Best regards,
 Antero Vipunen