in reply to Re: Writing threadsafe perl extensions
in thread Writing threadsafe perl extensions

I don't have Math::GMP, so I haven't checked whether any of this translates to that module

Pity ... that's the one I'm most interested in :-)
Given that the following script works fine:
#!perl -slw use Math::GMP; my $ret = Math::GMP->new('123' x 11); print Math::GMP::get_str_gmp($ret, 10); __END__ C:\_32\pscrpt\threads>perl gmp2.pl 123123123123123123123123123123123
if Math::GMP were threadsafe, would you expect that the following also outputs the same:
#!perl -slw use threads; use Math::GMP; sub t1 { my $mbi = Math::GMP->new($_[0]); return $mbi; } my $th1 = threads->new(\&t1, '123' x 11); my $ret1 = $th1->join; print Math::GMP::get_str_gmp($ret1, 10);
(It doesn't - it just segfaults.) Does that therefore prove that Math::GMP is not threadsafe ? - or is there yet a possible rendition that may prove fruitful ?

Cheers,
Rob

Replies are listed 'Best First'.
Re^3: Writing threadsafe perl extensions
by BrowserUk (Patriarch) on Oct 21, 2007 at 15:15 UTC

    What happens with this?

    #!perl -slw use threads; sub t1 { eval{ use Math::GMP }; my $mbi = Math::GMP->new($_[0]); return $mbi; } my $th1 = threads->new(\&t1, '123' x 11); my $ret1 = $th1->join; print Math::GMP::get_str_gmp($ret1, 10);

    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.
      What happens with this?

      Still segfaults, unfortunately.

      Cheers,
      Rob

        Sorry I can't help more. I grabbed Math::GMP and whilst it built fine, but craps out very early in make test with "The procedure entrypoint __gmpz_sqrt could not be located in the DLL gmp.dll". There seems to be a fundemental conflict between an XS extension to call functions in a file called gmp.dll, itself being called gmp.dll.

        (As an aside, why do so few of these modules that have dependancies on third party libraries never bother to give pointers to where to get them, or even mention the dependancy, in the POD?)


        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.