demetri wrote: > I have a problem with some FFI code that's almost certainly violating array > bounds somewhere. In plain C code I'd solve it with valgrind. If I > valgrind, say, a C main() with an embedded luajit I can't track the errors > to the call-site because the violated objects are created with ffi.new. If the code in question is compiled, you can use -jdump to write the generated traces to a file. Then search for the address that Valgrind complains about. The starting Lua location of that trace should be near the culprit. > I can presumably manually track the addresses of these objects, but I was > hoping people had a more sophisticated solution. The best I can do right > now is using a safe_new() which adds a metamethod that tracks accesses and > asserts that they're within some bounds. Is this the best practical > solution? Yes, extra bounds checking would another option. Might be easier if you have a good idea which kind of object causes the problem. --Mike