Skip Menu |

This queue is for tickets about the XS-Parse-Sublike CPAN distribution.

Report information
The Basics
Id: 133865
Status: patched
Priority: 0/
Queue: XS-Parse-Sublike

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

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



Subject: Segmentation fault when there is syntax error - content before the sub block starts
a segmentation fault will be caused by code like this: use strict; use warnings; use experimental qw(signatures); use Future::AsyncAwait; async sub test ($value) my $s = 's' { print $value; } test(1); there is a text `my $s = 's'` placed by mistake before the sub block but after the signature. if the signatures feature is disabled the error will be reported as usual.
On Fri Dec 04 03:39:40 2020, eyadof@gmail.com wrote: Show quoted text
> a segmentation fault will be caused by code like this: > > use strict; > use warnings; > > use experimental qw(signatures); > > use Future::AsyncAwait; > > async sub test ($value) > my $s = 's' { > print $value; > } > > test(1);
At first glance it appears actually to crash inside XS::Parse::Sublike: $ gdb --args perl -Mblib rt133865.pl ... (gdb) run Starting program: /usr/bin/perl -Mblib rt133865.pl [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7fb2c8c in ?? () from /usr/lib/x86_64-linux-gnu/perl5/5.32/auto/XS/Parse/Sublike/Sublike.so (gdb) bt #0 0x00007ffff7fb2c8c in ?? () from /usr/lib/x86_64-linux-gnu/perl5/5.32/auto/XS/Parse/Sublike/Sublike.so #1 0x00005555555ef035 in yyl_keylookup (my_perl=my_perl@entry=0x5555558dd2a0, s=0x55555594c465 "y $s = 's' {\n", s@entry=0x55555594c460 " my $s = 's' {\n", gv=<optimized out>) at toke.c:8556 #2 0x00005555555efc1b in yyl_try (my_perl=0x5555558dd2a0, s=<optimized out>) at toke.c:9128 #3 0x00005555555f3a84 in Perl_yylex (my_perl=0x5555558dd2a0) at toke.c:9438 #4 0x00005555555f67a4 in Perl_yyparse (my_perl=my_perl@entry=0x5555558dd2a0, gramtype=gramtype@entry=258) at perly.c:340 #5 0x00005555555c8117 in S_parse_body (xsinit=0x55555559c580 <xs_init>, env=0x0, my_perl=<optimized out>) at perl.c:2576 #6 perl_parse (my_perl=<optimized out>, xsinit=xsinit@entry=0x55555559c580 <xs_init>, argc=<optimized out>, argv=<optimized out>, env=env@entry=0x0) at perl.c:1871 #7 0x000055555559c3c3 in main (argc=<optimized out>, argv=<optimized out>, env=<optimized out>) at perlmain.c:126 -- Paul Evans
And now rebuilt locally with debug symbols: Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7fb2c24 in parse2 (hooksA=<optimized out>, hookdataA=0x0, hooksB=<optimized out>, hookdataB=0x0, op_ptr=0x7fffffffd9b8, my_perl=<optimized out>) at lib/XS/Parse/Sublike.xs:187 187 if (ctx.body->op_type == OP_STUB) { (gdb) bt #0 0x00007ffff7fb2c24 in parse2 (hooksA=<optimized out>, hookdataA=0x0, hooksB=<optimized out>, hookdataB=0x0, op_ptr=0x7fffffffd9b8, my_perl=<optimized out>) at lib/XS/Parse/Sublike.xs:187 ... -- Paul Evans
Simple oneline fix :) $ perl -Mblib rt133865.pl Semicolon seems to be missing at rt133865.pl line 12. syntax error at rt133865.pl line 9, near "my " Global symbol "$s" requires explicit package name (did you forget to declare "my $s"?) at rt133865.pl line 9. syntax error at rt133865.pl line 9, near "'s' {" Global symbol "$value" requires explicit package name (did you forget to declare "my $value"?) at rt133865.pl line 10. Execution of rt133865.pl aborted due to compilation errors. -- Paul Evans
Subject: rt133865.patch
=== modified file 'lib/XS/Parse/Sublike.xs' --- old/lib/XS/Parse/Sublike.xs 2020-06-19 21:53:50 +0000 +++ new/lib/XS/Parse/Sublike.xs 2020-12-07 08:52:14 +0000 @@ -180,7 +180,7 @@ SvREFCNT_inc(PL_compcv); #ifdef HAVE_PARSE_SUBSIGNATURE - if(sigop) { + if(ctx.body && sigop) { /* parse_block() returns an empy block as a stub op. * no need to keep that if we we have a signature. */