nif reload
Tony Rogvall <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.bugs |
|---|---|
| Message-ID | <[email protected]> |
Hi!
I have something strange niff stuff going on, I think.
(tested R17/R16)
I have a very simple demo nif application (attached), one function (not really needed) and
a nif that I want to be able to load/upgrade/unload. I have removed the reload callback,
that according to documentation is deprecated.
Following sequence can be seen, when I repeat the
> l(niffy).
from the erlang shell.
Eshell V6.1 (abort with ^G)
1> niffy:hello().
Loading: ./niffy/priv/niffy_drv
c_src/niffy_nif.c:61: niffy_load: *priv_data=0x0 ptr=0x1e1820e8, ptr->n
c_src/niffy_nif.c:51: niffy_hello: priv_data=0x1e1820e8
world
2> niffy:hello().
c_src/niffy_nif.c:51: niffy_hello: priv_data=0x1e1820e8
world
3> l(niffy).
Loading: ./niffy/priv/niffy_drv
c_src/niffy_nif.c:72: niffy_upgrade: *priv_data=0x0 *old_priv_data=0x1e1820e8 ptr->n=1
{module,niffy}
4> niffy:hello().
c_src/niffy_nif.c:51: niffy_hello: priv_data=0x1e1820e8
world
5> l(niffy).
c_src/niffy_nif.c:81: niffy_unload: priv_data=0x1e1820e8 ptr->n=2
Loading: ./niffy/priv/niffy_drv
c_src/niffy_nif.c:72: niffy_upgrade: *priv_data=0x0 *old_priv_data=0x1e1820e8 ptr->n=504889344
{module,niffy}
6>
6> l(niffy).
c_src/niffy_nif.c:81: niffy_unload: priv_data=0x1e1820e8 ptr->n=504889345
Loading: ./niffy/priv/niffy_drv
c_src/niffy_nif.c:72: niffy_upgrade: *priv_data=0x0 *old_priv_data=0x1e1820e8 ptr->n=504889344
{module,niffy}
7> l(niffy).
c_src/niffy_nif.c:81: niffy_unload: priv_data=0x1e1820e8 ptr->n=504889345
Segmentation fault: 11
I can see that the unload is called and I free the priv_data, then upgrade is called on that very same memory.
But why?
_______________________________________________
erlang-bugs mailing list
[email protected]
http://erlang.org/mailman/listinfo/erlang-bugs