<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div apple-content-edited="true"><span class="Apple-style-span" style="border-collapse: separate; orphans: 2; text-align: -webkit-auto; text-indent: 0px; widows: 2; border-spacing: 0px;"><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px; color: rgb(0, 0, 0); font-family: Helvetica;"><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; ">Hi!</span></div><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px; color: rgb(0, 0, 0); font-family: Helvetica;"><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; "><br></span></div><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px; color: rgb(0, 0, 0); font-family: Helvetica;"><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; ">I have something strange niff stuff going on, I think.</span></div><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px; color: rgb(0, 0, 0); font-family: Helvetica;"><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; ">(tested R17/R16)</span></div><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px; color: rgb(0, 0, 0); font-family: Helvetica;"><br></div><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;"><font color="#333333" face="Geneva, Arial, Helvetica, sans-serif">I have a very simple demo nif application (attached), one function (not really needed) and</font></div><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;"><font color="#333333" face="Geneva, Arial, Helvetica, sans-serif">a nif that I want to be able to load/upgrade/unload. I have removed the reload callback,</font></div><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;"><font color="#333333" face="Geneva, Arial, Helvetica, sans-serif">that according </font><span style="color: rgb(51, 51, 51); font-family: Geneva, Arial, Helvetica, sans-serif; text-align: -webkit-auto;">to documentation is deprecated.</span></div><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;"><br></div><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;">Following sequence can be seen, when I repeat the </div><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;">> l(niffy).</div><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;"><span style="text-align: -webkit-auto;">from the erlang shell.</span></div><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;"><br></div><div style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;"><br></div><div><font face="Courier">Eshell V6.1 (abort with ^G)<br>1> niffy:hello().<br>Loading: ./niffy/priv/niffy_drv<br>c_src/niffy_nif.c:61: niffy_load: *priv_data=0x0 ptr=0x1e1820e8, ptr->n<br>c_src/niffy_nif.c:51: niffy_hello: priv_data=0x1e1820e8<br>world<br>2> niffy:hello().<br>c_src/niffy_nif.c:51: niffy_hello: priv_data=0x1e1820e8<br>world<br>3> l(niffy).<br>Loading: ./niffy/priv/niffy_drv<br>c_src/niffy_nif.c:72: niffy_upgrade: *priv_data=0x0 *old_priv_data=0x1e1820e8 ptr->n=1<br>{module,niffy}<br>4> niffy:hello().<br>c_src/niffy_nif.c:51: niffy_hello: priv_data=0x1e1820e8<br>world<br>5> l(niffy). <br>c_src/niffy_nif.c:81: niffy_unload: priv_data=0x1e1820e8 ptr->n=2<br>Loading: ./niffy/priv/niffy_drv<br>c_src/niffy_nif.c:72: niffy_upgrade: *priv_data=0x0 *old_priv_data=0x1e1820e8 ptr->n=504889344<br>{module,niffy}<br>6> <br>6> l(niffy).<br>c_src/niffy_nif.c:81: niffy_unload: priv_data=0x1e1820e8 ptr->n=504889345<br>Loading: ./niffy/priv/niffy_drv<br>c_src/niffy_nif.c:72: niffy_upgrade: *priv_data=0x0 *old_priv_data=0x1e1820e8 ptr->n=504889344<br>{module,niffy}<br>7> l(niffy).<br>c_src/niffy_nif.c:81: niffy_unload: priv_data=0x1e1820e8 ptr->n=504889345<br>Segmentation fault: 11<br></font></div><div><font face="Courier"><br></font></div><div>I can see that the unload is called and I free the priv_data, then upgrade is called on that very same memory.</div><div>But why? </div><div><br></div><div></div></span></div></body></html>