in reply to Re^2: Perl crash during perl_clone
in thread Perl crash during perl_clone
except that the the coderef was passed into C code from Perl's "default" interpreter (the instance created automatically when I run perl.exe) & NOT from another interpreter/thread spawned by Perl (not sure the difference matters).
What you've described is exactly what I was trying and failing to describe. Two interpreters, one created by perl, one by your C code. And passing a code reference between those two. Perl will not allow you to attempt to pass a coderef between interpreters:
perl -Mthreads -Mthreads::shared -Mstrict -wle" my $c:shared; async{ ## This next line triggers the "Invalid value for shared scala +r" $c = sub{ print 'Hi'}; sleep 100 }->detach;; sleep 3; $c->(); sleep 100" Thread 1 terminated abnormally: Invalid value for shared scalar at -e +line 1. Can't use an undefined value as a subroutine reference at -e line 1.
But, by passing the coderef via C, you are by-passing this protection. Hence, as I surmised, if the callback gets triggered at a point in teh application when the "wrong" interpreter has the cpu, then it fails. Whereas if the originating inpterpreter is in control, it works,
The solution I'm afraid is to re-think your methodology. If you can describe why you are starting a second interpreter, we might be able to see a solution.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Perl crash during perl_clone
by perlmonk1729 (Acolyte) on Oct 28, 2010 at 06:01 UTC | |
by BrowserUk (Patriarch) on Oct 28, 2010 at 08:23 UTC | |
by perlmonk1729 (Acolyte) on Oct 28, 2010 at 11:31 UTC | |
by BrowserUk (Patriarch) on Oct 28, 2010 at 12:31 UTC | |
by perlmonk1729 (Acolyte) on Oct 28, 2010 at 17:52 UTC | |
|