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.
In reply to Re^19: Perl crash during perl_clone
by perlmonk1729
in thread Perl crash during perl_clone
by perlmonk1729
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |