Bug 771325 - perl segfaults on parsing invalid Perl code
Summary: perl segfaults on parsing invalid Perl code
Keywords:
Status: CLOSED CANTFIX
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: perl
Version: 6.2
Hardware: i386
OS: Unspecified
high
high
Target Milestone: rc
: ---
Assignee: perl-maint-list
QA Contact: Martin Kyral
URL: https://rt.perl.org/rt3/Public/Bug/Di...
Whiteboard:
Depends On:
Blocks: 836160 840699
TreeView+ depends on / blocked
 
Reported: 2012-01-03 10:37 UTC by Petr Pisar
Modified: 2012-12-10 09:11 UTC (History)
4 users (show)

Fixed In Version: perl-5.10.1-127.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-12-05 13:24:36 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Petr Pisar 2012-01-03 10:37:00 UTC
# perl -e 'do{}until(1)}'
Segmentation fault (core dumped)
# rpm -q perl
perl-5.10.1-119.el6_1.1.x86_64

See <https://rt.perl.org/rt3/Public/Bug/Display.html?id=72406> for more details.

Comment 2 Petr Pisar 2012-01-05 15:39:01 UTC
When checking development tree (git tag perl-5.10.1), `-l' option is needed to provoke SEGFAULT:

$ ./perl -I lib -e 'do{}until(1)}'
Unmatched right curly bracket at -e line 1, at end of line
syntax error at -e line 1, near ")}"
Execution of -e aborted due to compilation errors.

$ ./perl -I lib -le 'do{}until(1)}'
Neoprávněný přístup do paměti (SIGSEGV)

Comment 3 Petr Pisar 2012-01-05 17:03:25 UTC
5.10.1 is affected
5.11.0 is not affected

Bisect between 5.11.0 and common ancestor found this commit as first unaffected:

commit f9a01fbf80a2dfff95a408098b4f01fe2a12e140
Author: Steffen Mueller <wyp3rlx02>
Date:   Sat Aug 2 19:38:39 2008 +0200

    Tiny SelfLoader patch for better warnings
    Message-ID: <20080802153839.9538.qmail.com>
    Date: Sat, 02 Aug 2008 17:38:39 +0200

    p4raw-id: //depot/perl@34170

Comment 5 RHEL Program Management 2012-05-03 05:18:45 UTC
Since RHEL 6.3 External Beta has begun, and this bug remains
unresolved, it has been rejected as it is not proposed as
exception or blocker.

Red Hat invites you to ask your support representative to
propose this request, if appropriate and relevant, in the
next release of Red Hat Enterprise Linux.

Comment 8 Petr Pisar 2012-10-12 10:23:40 UTC
Now fix is known.

Comment 9 Petr Pisar 2012-10-12 10:53:17 UTC
I cannot reproduce it since perl-5.10.1-127.el6.x86_64.
I can reproduce it up to perl-5.10.1-126.el6.x86_64.

However there was not significant change between these two builds except enabling -Dusesitecustomize build-time option. Despite that valgring shows completely different and much shorter error log.

Comment 10 Petr Pisar 2012-10-12 11:01:40 UTC
(In reply to comment #8)
> Now fix is known.
No fix is know.

Comment 11 Petr Pisar 2012-10-12 11:12:01 UTC
(In reply to comment #9)
> However there was not significant change between these two builds except
> enabling -Dusesitecustomize build-time option. Despite that valgring shows
> completely different and much shorter error log.

It turned out I had sitecustomize.pl, which started loaded with the 127 release. Without the file 127 and newer releases do not show any flaws under valgrind and interpreter does not seg fault.

Comment 12 Martin Kyral 2012-11-29 15:07:09 UTC
The bug is still present on i386 (both .127 and .128), other architectures are ok:

.qa.[root@hp-dl360-05 ~]# perl -I lib -le 'do{}until(1)}'
Segmentation fault (core dumped)

.qa.[root@hp-dl360-05 ~]# valgrind perl -I lib -le 'do{}until(1)}'
==19053== Memcheck, a memory error detector
==19053== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==19053== Using Valgrind-3.6.0 and LibVEX; rerun with -h for copyright info
==19053== Command: perl -I lib -le do{}until(1)}
==19053== 
==19053== Invalid read of size 1
==19053==    at 0x40339C8: Perl_peep (op.c:8264)
==19053==    by 0x4038F56: Perl_newPROG (op.c:2327)
==19053==    by 0x4072556: Perl_yyparse (perly.y:142)
==19053==    by 0x4047E76: S_parse_body (perl.c:2278)
==19053==    by 0x404AAA7: perl_parse (perl.c:1691)
==19053==    by 0x8048977: main (perlmain.c:115)
==19053==  Address 0x110 is not stack'd, malloc'd or (recently) free'd
==19053== 
==19053== 
==19053== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==19053==  Access not within mapped region at address 0x110
==19053==    at 0x40339C8: Perl_peep (op.c:8264)
==19053==    by 0x4038F56: Perl_newPROG (op.c:2327)
==19053==    by 0x4072556: Perl_yyparse (perly.y:142)
==19053==    by 0x4047E76: S_parse_body (perl.c:2278)
==19053==    by 0x404AAA7: perl_parse (perl.c:1691)
==19053==    by 0x8048977: main (perlmain.c:115)
==19053==  If you believe this happened as a result of a stack
==19053==  overflow in your program's main thread (unlikely but
==19053==  possible), you can try to increase the size of the
==19053==  main thread stack using the --main-stacksize= flag.
==19053==  The main thread stack size used in this run was 10485760.
==19053== 
==19053== HEAP SUMMARY:
==19053==     in use at exit: 131,909 bytes in 648 blocks
==19053==   total heap usage: 763 allocs, 115 frees, 136,772 bytes allocated
==19053== 
==19053== LEAK SUMMARY:
==19053==    definitely lost: 176 bytes in 1 blocks
==19053==    indirectly lost: 2,735 bytes in 42 blocks
==19053==      possibly lost: 16 bytes in 1 blocks
==19053==    still reachable: 128,982 bytes in 604 blocks
==19053==         suppressed: 0 bytes in 0 blocks
==19053== Rerun with --leak-check=full to see details of leaked memory
==19053== 
==19053== For counts of detected and suppressed errors, rerun with: -v
==19053== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 22 from 8)
Segmentation fault (core dumped)

.qa.[root@hp-dl360-05 ~]# rpm -q perl
perl-5.10.1-128.el6.i686

.qa.[root@hp-dl360-05 ~]# gdb core.18947
....
(gdb) i th
* 1 Thread 0xb77d36c0 (LWP 18947)  Perl_peep (my_perl=0x808b008, o=<value optimized out>) at op.c:8264
(gdb) t a a bt

Thread 1 (Thread 0xb77d36c0 (LWP 18947)):
#0  Perl_peep (my_perl=0x808b008, o=<value optimized out>) at op.c:8264
#1  0x0074df57 in Perl_newPROG (my_perl=0x808b008, o=0x80acc98) at op.c:2327
#2  0x00787557 in Perl_yyparse (my_perl=0x808b008) at perly.y:142
#3  0x0075ce77 in S_parse_body (my_perl=0x808b008, env=0x0, xsinit=0x8048a00 <xs_init>) at perl.c:2278
#4  0x0075faa8 in perl_parse (my_perl=0x808b008, xsinit=0x8048a00 <xs_init>, argc=5, argv=0xbfbeaf24, env=0x0)
    at perl.c:1691
#5  0x08048978 in main (argc=5, argv=0xbfbeaf24, env=0xbfbeaf3c) at perlmain.c:115
(gdb)

Comment 14 Petr Pisar 2012-12-05 13:24:36 UTC
No fix is known. The bug exhibits on i386 only. Newer Perl versions (5.16 in RHEL-7) seems not tainted.


Note You need to log in before you can comment on or make changes to this bug.