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

Crash when dying on warning from backticks with vfork() (5.6.1 on Lamp)

Thread Next
From:
Joshua Juran
Date:
September 28, 2008 22:05
Subject:
Crash when dying on warning from backticks with vfork() (5.6.1 on Lamp)
Message ID:
E7F914D9-D38A-496D-90D7-CA7C240397D6@gmail.com
What is Lamp?  Lamp ain't Mac POSIX.  It's like Cygwin for  
traditional Mac OS.  In most respects it behaves like Unix, though it  
has no fork() and must use vfork() instead.

$ perl -we '$SIG{__WARN__} = sub { die }; `/dev/null/`;'
Illegal instruction

What happens is that perl vforks and tries to exec, but gets an error  
(since /dev/null isn't executable).  It issues a warning, which  
invokes a sub which dies, and thereby longjmps back to perl_run(),  
which is wrong because it's the child of a vfork() further down the  
stack.  Soon after perl's main() calls exit(), the _exit() system  
call tries to resume the vfork() as the parent, by which point the  
stack is undefined.

A related issue exists for fork-enabled systems:

$ perl -we '$SIG{__WARN__} = sub { die }; `/dev/null/`;'
Died at -e line 1.
$ echo $?
0
$ perl -v | head -2 | tail -1
This is perl, v5.10.0 built for i486-linux-gnu-thread-multi

Arguably, perl shouldn't be indicating success in the presence of an  
uncaught exception.  In this case, perhaps the child should merely  
communicate the failure back to the parent, and let it issue the  
warning, which would solve both problems.

Josh



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