develooper Front page | perl.perl5.porters | Postings from December 2008

Possible bug: Perl 5.10.0 does not set $? & 128 when dumping core

Thread Next
From:
Paul Fenwick
Date:
December 16, 2008 00:55
Subject:
Possible bug: Perl 5.10.0 does not set $? & 128 when dumping core
Message ID:
49476CB4.3040603@perltraining.com.au
G'day everyone,

I've been working with the Debian Perl list, who have found an oddity with
how Perl works with $?

With thanks to Niko Tyni:

# perl -le 'system($^X, "-e", q/kill 6,$$; sleep 1/); print "version=$^V
\$?=$? native=${^CHILD_ERROR_NATIVE}"'

Signal 6 is a SIGABRT, which most systems interpret as a request to dump
core.  This gives us:

	version=v5.10.0 $?=6 native=134

	version=5.008008 $?=134 native=

Notice that Perl 5.8 has the expected $? value of 134 (128 for a core dump,
plus 6 for the signal).  Perl 5.10 seems to strip the core dump info out of
$?, but provides the original value in ${^CHILD_ERROR_NATIVE}.

At least from my understanding about how $? *should* be working, and the
documentation in 'perldoc -f system', this looks like a bug.  Any code
(including my own) that relies upon testing $? & 128 to detect core dumps is
going to fail.

Unfortunately I'm still travelling, so I don't have a Unix machine with 5.10
handy to test this.  May I ask:

	a) If anyone else can produce the same results on a
	   non-Debian system.

	b) If this is considered a bug.  (If not, we need to
	   update perlfunc.pod)

	c) If I can rely upon 5.10 setting ${^CHILD_ERROR_NATIVE} to
	   what I consider to be the "correct" value (so I don't have
	   code that works around the problem on 5.10.0, but breaks
	   on 5.10.1).

If this is considered a bug, I can file a report in RT.

Many thanks to Gregor Hermann, Jonas Smedegaard, Jonathan Yu, and Niko Tyni
for tracking down this problem.

All the very best,

	Paul

-- 
Paul Fenwick <pjf@perltraining.com.au> | http://perltraining.com.au/
Director of Training                   | Ph:  +61 3 9354 6001
Perl Training Australia                | Fax: +61 3 9354 2681

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About