[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: LuaJIT segfault
- From: Pierre Chapuis <catwell@...>
- Date: Tue, 08 Nov 2011 11:42:58 +0100
On 08.11.2011 11:30, Daurnimator wrote:
Byte arrays may also be initialized with a Lua string. This copies
whole string plus a terminating zero-byte. The copy stops early only
if the array has a known, fixed size.
I guess a VLA (A variable-length array) is not of a known, fixed
(though I guess it should be.....)
My reasoning is: I'm using nelem
(http://luajit.org/ext_ffi_api.html#ffi_new) to copy a string that
represents raw bytes (and has no reason to be \0-terminated).
It should behave approximately like strncpy().
But what I find the most strange is that the segfault doesn't happen
at that line, it happens later when the memory is garbage collected.