lua-users home
lua-l archive

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


I'm trying to pursue porting Lua to Go language's C compiler[1], and
currently I'm stuck at an error in the Lua testsuite, in "gc.lua" -
console output looks like this:

    testing garbage collection
    tables
    strings
    functions
    functions with errors
    long strings
    ---
    pre:    194
    stop:   59
    peak:   71
    after:  62
    result: 1
    PANIC: unprotected error in call to Lua API ([string "from
loadbuffer"]:117: assertion failed!)

The contents below the "---" line is from patched "dosteps()", which
now looks like this:

    local function dosteps (siz)
      print("---\npre:", gcinfo())      -- added
      collectgarbage()
      collectgarbage"stop"
      print("stop:", gcinfo())      -- added
      local a = {}
      for i=1,100 do a[i] = {{}}; local b = {} end
      local x = gcinfo()
      local i = 0
      repeat
        i = i+1
      until collectgarbage("step", siz)
      assert(gcinfo() < x)
      print("peak:", x)      -- added
      print("after:", gcinfo())      -- added
      print("result:", i)      -- added
      return i
    end

The line number 117 is in slightly modified source, so it should be
understood as line 111 in original "gc.lua", i.e.:

    assert(dosteps(0) > 10)

The problem is, I don't have a clue where to start searching. The most
probable culprit would be some function in my version of Standard C
Library (I needed to implement most of the library by myself), as has
already happened a few times during this project. But I can't see any
immediately suspicious call near the retval from
`luaB_collectgarbage()`.

Could you have any advice or suggestion as to how to narrow down on
the bug? I suppose it can actually introduce inconsistency at some
much earlier place, but in such a way that it can only manifest during
garbage collection. Ah, and by the way, the "calls.lua" is the only
other test I tried till now, and I got it to pass.

    [1]: http://github.com/akavel/goluago

I'd be grateful for any help --
Thanks
/Mateusz Czapliński.