in reply to Re^18: Perl crash during perl_clone
in thread Perl crash during perl_clone
I may have made some other mistake when I tried the SWIG wrapper experiment.
Its quite late in the night here and I hope I'm not celebrating too early: I think I figured out the cause for the seg-faults in the sample code (myModule version) and my real project.
The problem seems to be that the \&module:sub syntax is somehow a temporary reference and was out of scope by the time my callback was invoked. The reason it worked in one of my callbacks was sheer coincidence: a scalar that was holding a reference to the sub was still in scope when the callback is called.
In the RegisterCB function, by doing a newSVsv() and then using that new SV as the PCB always seem to keep the reference in scope/valid when the PCB is called. This newSVsv() was in the first version of my code that did the perl_clone, but I had removed it along with a bunch of other code, thinking it was not necessary.
I'll try to reconfirm tomorrow when I'm more awake :-) Let me know if it works for you and if it makes sense.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^20: Perl crash during perl_clone
by BrowserUk (Patriarch) on Nov 08, 2010 at 19:21 UTC | |
by perlmonk1729 (Acolyte) on Nov 09, 2010 at 04:49 UTC | |
by BrowserUk (Patriarch) on Nov 09, 2010 at 06:59 UTC | |
by perlmonk1729 (Acolyte) on Nov 09, 2010 at 11:17 UTC | |
by BrowserUk (Patriarch) on Nov 09, 2010 at 12:06 UTC | |
|