in reply to xs, threads and panic

I've encountered similar problems trying to use callbacks from XS & Inline::C with 5.10. Code that worked at 5.8.x (with and without threads).

I suspect, but cannot definitively prove, that when the internal structures were revamped circa 5,9.something to reduce memory consumption, one or more of the macros involved in performing callbacks were not updated (correctly) and the testing slipped through the cracks.

Try running your code under 5.8.8 (or earlier) and see if that makes the problem 'go away'. If so, you may have a test case simple enough that p5p will accept it as a demonstration of real internals error rather than decrying it as user error; too verbose; wrong platform; or some other excuse for ignoring it.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^2: xs, threads and panic
by Anonymous Monk on May 20, 2009 at 10:16 UTC
    Thanks, BrowserUk, for answer!
    I have installed perl5.8.9 (pervious stable version) and error has gone away. It is cool, but script does not work correctly, it does not print "MESSAGE: Hellow world!!!". And I steel don't know, why =\
    Note, if we remove threads from code:
    change
    my $thread = threads->create(sub {$obj->run(&MESSAGE)}) or exit(1); $thread->join();
    to
    my $callback = sub {$obj->run(&MESSAGE)}; $callback->();
    It works fine.

      Okay. So you are trying to bypass the check that prevent you from passing a reference to a subroutine, by calling into XS and creating an oblique code reference and passing that between threads; and then complaining that it crashes when you bypass the mechanism put in place to prevent you from doing that.

      That's cool. WAD. Working as designed. You reach behind the fireguard and get burned.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        I tried to help the OP with help from perlcall
        void registCallback(cb) SV* cb; PROTOTYPE: $ PPCODE: if (callback_ref == (SV*)NULL) { callback_ref = newSVsv((SV*)cb); } else { SvSetSV(callback_ref, cb); }
        I didn't realize it was WAD after getting error
        Bizarre copy of CODE in entersub (#1) (P) Perl detected an attempt to copy an internal value that is not copyable.
        :)