Skip to content

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

Description

@benmercs

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

Activity

  1. greatwolf commented on Aug 9, 2013

    @greatwolf
    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?

  2. greatwolf commented on Aug 9, 2013

    @greatwolf
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions