lua-users home
lua-l archive

[LuaJIT FFI] Tailcalling string.byte() in a callback causes LuaJIT to crash

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


Just discovered this (running on Windows 7):
LuaJIT 2.0.0-beta9 -- Copyright (C) 2005-2011 Mike Pall. http://luajit.org/
JIT: ON CMOV SSE2 SSE3 SSE4.1 fold cse dce fwd dse narrow loop abc fuse
> ffi = require 'ffi'
> func = ffi.cast('int(*)()', function() return string.byte 'a'; end)
> =func()
(...CRASH!!)
Forcing a non-tailcall fixes it:
LuaJIT 2.0.0-beta9 -- Copyright (C) 2005-2011 Mike Pall. http://luajit.org/
JIT: ON CMOV SSE2 SSE3 SSE4.1 fold cse dce fwd dse narrow loop abc fuse
> ffi = require 'ffi'
> func = ffi.cast('int(*)()', function() return (string.byte 'a'); end)
> =func()
97
-Duncan

AltStyle によって変換されたページ (->オリジナル) /