-
Notifications
You must be signed in to change notification settings - Fork 555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Catching SIGFPE #19081
Comments
That is correct
$PERL -MPOSIX=sigaction,SIGFPE -MMath::GMP -wle '$z = Math::GMP->new(1); sigaction(SIGFPE, POSIX::SigAction->new(sub { die "divide by zero" })); print $z/0' |
Thanks Leon; I've been looking more carefully through the docs (perlvar, perlipc, POSIX) to check if I should have been able to discover this myself, or to see if there is improvement possible there. While there is some discussion of deferred signals, I don't see anything much pointing me at the above solution. However I do find this, in perlipc:
.. which makes me wonder whether FPE should be classed as a "fault" in this sense, and if so whether Perl should be treating it the same way. If I understand the above paragraph correctly, such a change in Perl's handling of FPE would make it possible to catch it directly via |
That sounds reasonable to me, it really is a fault. Though all of them should come with the explicit warning that such a handler should die. |
I've created PR #19090 for this, including having a go at wording for such a warning. Having said that, for some the preferred pattern might be more like:
|
For the record, a PerlMonks question prompted me to discover that if the
That makes no sense to me - @Leont can you make sense of it? If there may be a bug here, I'll open a separate ticket. |
I can't reproduce that. I think we're dealing with undefined behavior here.
Given it only happens in an older release, I'm not sure that makes sense. |
I don't know if it's possible to trigger in pure perl, but it is possible to get division by zero in external libraries, eg:
I thought it might be possible to catch that so as to use
die
orconfess
to get more information about the error, but that doesn't appear to work:I assume this is because of perl's deferred signals logic, does anyone know of a way to get around that?
Failing that, is there a way to get a perl-level stack trace via gdb with a core dump?
Tested with recent blead:
The text was updated successfully, but these errors were encountered: