Re: Segfault from nil table access when using ffi.gc

  • From: Gerhard Fuernkranz <nospam456@xxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sun, 13 Nov 2016 16:07:57 +0100


> From: Peter Cawley <corsix@xxxxxxxxxx>
> To: luajit@xxxxxxxxxxxxx
> Date: Fri, 11 Nov 2016 22:02:25 +0000

I suspect the following sequence of events is occurring:
1. Your local variable called `test` is garbage collected, thus
unloading `libtest.so`.
2. Your local variable called `cells` is garbage collected, thus
calling `Abc_destruct`.
3. The code for `Abc_destruct` is no longer present in memory, thus
resulting in a segfault.

I'm wondering:

Is a live reference to a function in a C namespace not supposed to keep the 
namespace object live as well, preventing unload of the .so?


Thanks,
Gerhard



Other related posts: