Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Bug in Math::Pari ?

by unlox775 (Initiate)
on Nov 25, 2009 at 23:30 UTC ( [id://809457]=note: print w/replies, xml ) Need Help??


in reply to Re: Bug in Math::Pari ?
in thread Bug in Math::Pari ?

BTW, I'm still seeing this... I'm trying to get Net::SFTP working, which is calling Net::SSH::Perl which is using Math::BigInt which is using Math::Pari. Here is the whole caller trace (caught using a $SIG{__DIE__}):
'__ANON__ called at Math/Pari.pm line 1148', '(eval) called at Math/Pari.pm line 1148', 'can called at Math/BigInt.pm line 2559', 'objectify called at Math/BigInt.pm line 1757', 'bmod called at Math/BigInt.pm line 114', '__ANON__ called at Net/SSH/Perl/Util/SSH2MP.pm line 28', 'mp2bin called at Net/SSH/Perl/Buffer.pm line 173', '_put_mp_int_ssh2 called at Net/SSH/Perl/Buffer.pm line 138' +, 'put_mp_int called at Net/SSH/Perl/Kex.pm line 179', 'derive_key called at Net/SSH/Perl/Kex.pm line 163', 'derive_keys called at Net/SSH/Perl/Kex/DH1.pm line 76', 'exchange called at Net/SSH/Perl/Kex.pm line 100', 'exchange called at Net/SSH/Perl/SSH2.pm line 92', '_login called at Net/SSH/Perl/SSH2.pm line 69', 'login called at Net/SFTP.pm line 62', 'init called at Net/SFTP.pm line 24', 'new called at -e line 1'
Yes, the line it is dying on is this one:
sub can { my ($obj, $meth) = (@_); my $f = $obj->SUPER::can($meth); return $f if defined $f; # There is no "usual" way to get the function; try loadPari() $f = eval { loadPari($meth) }; # <-- THIS LINE return $f if defined $f; return; }
So, I'm guessing it's when the loadPari function is getting called. This function must be defined in the Dynaloader (Pari.bs or Pari.so files). I know Perl ok, but when it hits this compiled stuff I don't know how to proceed. By deduction I assume it's trying to load some C-defined function that isn't present. Now, the as_number() function has been defined in the Math::BigInt since v1.22 (2001-04-05), so I think it's not likely that it's just a newly added function and I don't have the newest function... So I'm thinking I don't have another lib that these .so and .bs files need? libpari? I'll keep looking. (And BTW, you guys were unduely harsh to this guy who seems to have been doing his best to learn... "call to the closest available guru" sheesh...)

Replies are listed 'Best First'.
Re^3: Bug in Math::Pari ?
by salva (Canon) on Nov 25, 2009 at 23:52 UTC
Re^3: Bug in Math::Pari ?
by hv (Prior) on Nov 27, 2009 at 12:58 UTC

    I wonder if $SIG{__DIE__} is exactly the problem here: the line in Math::BigInt::objectify() is:

    $k->can('as_number') ? $k = $k->as_number : $k = $a[0]->new($k);

    Now, there is a precedence error here (I've reported that), but if can() returns false it shouldn't affect us, it should simply call $a[0]->new($k).

    The code from Math::Pari::can() is:

    $f = eval { loadPari($meth) }; return $f if defined $f; return;

    .. which should correctly return undef if the loadPari() fails. However if some $SIG{__DIE__} is catching the loadPari() failure, maybe we're never getting to return from the eval. Or maybe the die handler is (inappropriately) reporting the error and the code is then successfully continuing.

    I'd be tempted for starters to put a diagnostic in objectify() just after that line, to see if a) it reaches there, and b) $k has the correct value. I'd also hunt for a $SIG{__DIE__} handler, to check what exactly it is doing - generally, such handlers should almost always act only after checking they are not inside an eval. There may be a better way, but when I needed this some time ago for a logging module the code looked like this:

    $SIG{__DIE__} = sub { # propagate the die if we're under an eval (defined($^S) && !$^S) or die(@_); # now do the real stuff ... };

    .. but there may be a better way.

    Hugo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://809457]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-03-29 12:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found