Skip to content

pairs/ipairs proxies crash under non-main coroutine #46

@glycerine

Description

@glycerine

minimized reproducer, under LuaJIT 2.1.0-beta3, on darwin OSX, amd64, go1.9.1

raw luajit gi> coroutine.resume(coroutine.create(function() for i,k in pairs({hello="world"}) do end; end))
error from Lua vm.Call(0,0): '[string "coroutine.resume(coroutine.create(function() ..."]:1: bad argument #1 to 'resume' (table expected, got thread)'. supplied lua with: 'coroutine.resume(coroutine.create(function() for i,k in pairs({hello="world"}) do end; end)'
lua stack:

========== begin DumpLuaStack: top = 1
DumpLuaStack: i=1, t= 4
 String :   [string "coroutine.resume(coroutine.create(function() ..."]:1: bad argument #1 to 'resume' (table expected, got thread)
========= end of DumpLuaStack

raw luajit gi>

if I turn off the pairs proxy, no problem:

raw luajit gi> coroutine.resume(coroutine.create(function() for i,k in pairs({hello="world"}) do end; end))

elapsed: '35.82µs'
raw luajit gi>

similary, with the ipairs proxy in place, crash:

raw luajit gi> coroutine.resume(coroutine.create(function() for i,k in ipairs({[1]="world"}) do end; end))
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x104ce5828 pc=0x44b8650]

runtime stack:
runtime.throw(0x4624309, 0x2a)
    /usr/local/go/src/runtime/panic.go:605 +0x95
runtime.sigpanic()
    /usr/local/go/src/runtime/signal_unix.go:351 +0x2b8

goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x44b5a00, 0xc42005bb20, 0x42a0100)
    /usr/local/go/src/runtime/cgocall.go:132 +0xe4 fp=0xc42005bad8 sp=0xc42005ba98 pc=0x4004414
github.com/gijit/gi/vendor/github.com/glycerine/golua/lua._Cfunc_lua_pcall(0x4c80378, 0x0, 0x1, 0x0)
    github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/_obj/_cgo_gotypes.go:1191 +0x4d fp=0xc42005bb20 sp=0xc42005bad8 pc=0x42a585d
github.com/gijit/gi/vendor/github.com/glycerine/golua/lua.(*State).pcall.func1(0x4c80378, 0x0, 0x1, 0x1)
    /Users/jaten/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/lua.go:176 +0x78 fp=0xc42005bb58 sp=0xc42005bb20 pc=0x42af978
github.com/gijit/gi/vendor/github.com/glycerine/golua/lua.(*State).pcall(0xc420067800, 0x0, 0x0, 0x1, 0x44b4c10)
    /Users/jaten/go/src/github.com/gijit/gi/vendor/github.com/glycerine/golua/lua/lua.go:176 +0x49 fp=0xc42005bb88 sp=0xc42005bb58 pc=0x42aae19
...

without the ipairs proxy, no crash:

raw luajit gi> coroutine.resume(coroutine.create(function() for i,k in ipairs({[1]="world"}) do end; end))

elapsed: '30.906µs'
raw luajit gi>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions