Iterating lua.globals and storing items causes heap crash
This simple python program will cause a heap crash:
import lua
lg = lua.globals ()
lgList = []
for item in lg: lgList.append (item)
Running this in valgrind reveals a write into a free'd buffer. Wouldn't there be a mishandled reference counter somewhere?
I'm about to use lunatic quite a lot, so... you'll probably hear from me a bit :)
Thanks for testing and feedback! :)
I just tried this on win7 64bit with python 3.3.0 but I can't reproduce the crash you're seeing. I'll try this on a linux vm later. Do you have a stacktrace or an annotated coredump of the crash? It'll help give an idea where the crash is happening. Does the crash still happen if you use another lua table with few items?
Can anyone else look into this and report back what's found?
It looks like lua tables with a lot of entries reproduces this error. For example, testing this in virtualbox under linuxlite python 2.7.3:
import lua
f = lua.eval("function (n) local t = {}; for i = 1, n do table.insert(t, i) end return t end")
lg = f(36)
l = []
for each in lg:
l.append(each)
print(l)
I found that if n > 35 will trigger a segfault. Still not clear why. My best guess is maybe lunatic is using up all virtual stack space somewhere. A quick search in the lunatic source shows that at no point does it ever call lua_checkstack.