On Fri, Aug 31, 2001 at 12:31:52AM -0700, John Theus wrote: > % perl -cw core_test.pl > Unquoted string "b" may clash with future reserved word at core_test.pl line 3. > Name "main::a" used only once: possible typo at core_test.pl line 3. > Name "main::b" used only once: possible typo at core_test.pl line 3. > core_test.pl syntax OK > zsh: segmentation fault (core dumped) perl -cw core_test.pl This appears to have been fixed in bleadperl. Hmmm... with an eye towards writing a test for this, how do you run a program and reliably tell that it's segfaulted? WCOREDUMP doesn't appear to be universal. Best I can do is check to see if it exited with 255 and the right output, which appears to be perl's normal exit code on a syntax error. I also can't seem to get `` to pipe STDERR to STDOUT using like I did in lib/warnings.t, so I'll have to use 2>&1 and just skip on Win32 and VMS for the moment :( Right. Here's a new test where we can stick all these little bits of code that cause segfaults. Hopefully someone can fix the 2>&1 problem. --- /dev/null Sun Jul 1 22:55:26 2001 +++ t/run/segfault.t Fri Aug 31 15:35:08 2001 @@ -0,0 +1,43 @@ +#!./perl +# +# Tests for things which have caused segfaults in the past. + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; +} + +# VMS and Windows need -e "...", most everything else works better with ' +my $quote = $^O =~ /^(VMS|MSWin\d+)$/ ? q{"} : q{'}; + +my $IsVMS = $^O eq 'VMS'; + + +BEGIN { + if( $^O =~ /^(VMS|MSWin\d+)$/ ) { + print "1..0 # Skipped: platform temporarily not supported\n"; + exit; + } +} + + +# Run some code, check that it has the expected output and exits +# with the code for a perl syntax error. +sub chk_segfault { + my($code, $expect, $name) = @_; + my $cmd = "$^X -e "; + + # I *think* these are the right exit codes for syntax error. + my $expected_exit = $IsVMS ? 4 : 255; + + my $out = `$cmd$quote$code$quote 2>&1`; + + is( $? >> 8, $expected_exit, "$name - exit as expected" ); + like( $out, qr/$expect at -e line 1/, ' with the right output' ); +} + +use Test::More tests => 2; + +chk_segfault('($a, b) = (1, 2)', + "Can't modify constant item in list assignment", + 'perlbug ID 20010831.001'); -- Michael G. Schwern <schwern@pobox.com> http://www.pobox.com/~schwern/ Perl6 Quality Assurance <perl-qa@perl.org> Kwalitee Is Job One That which stirs me, stirs everything. -- Squonk Opera, "Spoon"Thread Previous