halfcountplus has asked for the wisdom of the Perl Monks concerning the following question:

This seems to me to be a bug, I just wanted to see if anyone had seen it before and if it reproduces for them.

#!/usr/bin/perl use strict; use warnings FATAL => qw(all); my $t = test->new(); print "The End.\n"; { package test; sub new { my $class = shift; my $self = { list => [ 'a', 'b', 'c' ] }; bless $self, $class; } sub DESTROY { my $self = shift; print STDERR "Bye!".$self->{list}->{4}."\n"; } 1; }
Using perl "(v5.18.4) built for x86_64-linux-thread-multi", rather than the nice runtime warning:
The End.
        (in cleanup) Not a HASH reference at ./test.pl line 20.
I get:
The End.
shell: Job 1, “./test.pl” terminated by signal SIGSEGV (Address boundary error)
Which is tedious to then actually pinpoint if the code is more elaborate. Fortunately the deciding factor is:
use warnings FATAL => qw(all);
Just plain `warnings` or `-w` won't do it. The backtrace starts in malloc.c and leads to an endless loop involving "Perl_ck_warner()" where it seems to have been trying to generate the "(in cleanup)" error message.

Replies are listed 'Best First'.
Re: SIGSEGV instead of "Not a hash ref" in destructor w/ FATAL => all
by Anonymous Monk on Jul 20, 2015 at 10:23 UTC

    In recent versions of Perl, warnings says:

    NOTE: FATAL warnings should be used with care, particularly FATAL => 'all'.

    Libraries using warnings::warn for custom warning categories generally don't expect warnings::warn to be fatal and can wind up in an unexpected state as a result. For XS modules issuing categorized warnings, such unanticipated exceptions could also expose memory leak bugs.

    Moreover, the Perl interpreter itself has had serious bugs involving fatalized warnings. For a summary of resolved and unresolved problems as of January 2015, please see this perl5-porters post.

    Sounds like you may have run into just such a bug, in fact your code looks quite similar to that in #123398. Although it looks like there's a patch for that issue, the general recommendation would be to not use FATAL => 'all', especially in light of the additional reasons to avoid it listed in the documentation. If you wanted to submit a bug via perlbug, I would suspect that because of the above it won't get a high priority unless you provide a patch or can show that it also causes a problem when warnings aren't fatalized.

      Thanks for #123398; that definitely is it.

      There is a patch, and the last post there currently is about 5 weeks ago (June 8), when the bug status was switched to "pending release", which apparently means "we fixed the bug, but only in dev, and not yet in production".

      I only need/want `FATAL => all` in testing, so no big deal. Just nice to know definitively what the problem is.