Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iterating lua.globals and storing items causes heap crash #18

Open
benmercs opened this issue Aug 9, 2013 · 2 comments
Open

Iterating lua.globals and storing items causes heap crash #18

benmercs opened this issue Aug 9, 2013 · 2 comments
Labels

Comments

@benmercs
Copy link

benmercs commented Aug 9, 2013

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 :)

@greatwolf
Copy link
Collaborator

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?

@greatwolf
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants