Skip Menu |

This queue is for tickets about the Try-Tiny CPAN distribution.

Report information
The Basics
Id: 61306
Status: rejected
Priority: 0/
Queue: Try-Tiny

People
Owner: Nobody in particular
Requestors: andrew.clegg [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Syntax error in finally block can cause perl to segfault
Date: Mon, 13 Sep 2010 18:42:50 +0100
To: bug-Try-Tiny [...] rt.cpan.org
From: Andrew Clegg <andrew.clegg [...] gmail.com>
I have found a situation where a syntax error in a finally block can cause perl to segfault, even if just run with perl -c. A file to reproduce this (Broken.pm) is appended to the end of this message. The syntax error is on line 14 -- the extra semicolon after the chdir() call. If I comment out all the lines relating to try and finally, leaving just lines 14 and 15 to run, I get a normal syntax error message. To demonstrate the problem, just perl -c Broken.pm The same thing happens if you 'use Broken' and create a new Broken object. OS: Centos 5.4, Linux x86_64 2.6.18-164.15.1.el5 Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=linux, osvers=2.6.9-42.0.3.elsmp, archname=x86_64-linux uname='linux fletcher 2.6.9-42.0.3.elsmp #1 smp fri oct 6 06:28:26 cdt 2006 x86_64 x86_64 x86_64 gnulinux ' config_args='-Doptimize=-g -Dprefix=/cath/opt/perl-5.8.8-centos4 -de' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=define use64bitall=define uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-DDEBUGGING -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm', optimize='-g', cppflags='-DDEBUGGING -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -I/usr/include/gdbm' ccversion='', gccversion='3.4.6 20060404 (Red Hat 3.4.6-10)', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -ldl -lm -lcrypt -lutil -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc libc=/lib/libc-2.3.4.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.3.4' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib' Modules in use: Try::Tiny 0.06 Moose 1.09 Cwd 3.3 *** Broken.pm *** package Broken; use Moose; use Cwd; use Try::Tiny; sub _process { my $self = shift; my $orig_dir = cwd; try { } finally { chdir( '/' ); or warn( "Failed to change back to $orig_dir" ); }; } sub BUILD { my $self = shift; $self->_process; } no Moose; __PACKAGE__->meta->make_immutable; 1;
Congratulations, you found a bug in perl! However, it's an already fixed bug. On perl 5.12.2, for example, you get the error message you'd expect: $ perl -c /tmp/Broken.pm syntax error at /tmp/Broken.pm line 14, near "or" BEGIN not safe after errors--compilation aborted at /tmp/Broken.pm line 23. There's really nothing Try::Tiny can do about this, and it is in fact not even required to reproduce this bug failure. Try removing 'use Try::Tiny', and do sub try (&;@) { } sub finally (&;@) { } instead. I highly recommend upgrading to a newer version of perl.
Subject: Re: [rt.cpan.org #61306] Syntax error in finally block can cause perl to segfault
Date: Mon, 13 Sep 2010 21:33:28 +0100
To: bug-Try-Tiny [...] rt.cpan.org
From: Andrew Clegg <andrew.clegg [...] gmail.com>
Thanks for the very rapid response, Florian! On 13 September 2010 21:28, Florian Ragwitz via RT <bug-Try-Tiny@rt.cpan.org> wrote: Show quoted text
> I highly recommend upgrading to a newer version of perl.
I will see what we can do -- this is a centrally-installed perl that a number of servers depend on. Known bugs are a pretty good reason to upgrade them all, though... Cheers, Andrew. -- :: http://biotext.org.uk/ ::