New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
null ptr deref -> Perl_pp_iter () at pp_hot.c:2348 #14563
Comments
From @geeknikBuilt v5.21.10 (v5.21.9-73-gd98e5cd) with the following command line: ./Configure -des -Dusedevel -DDEBUGGING -Dcc=afl-gcc -Doptimize=-O2\ -g && AFL_HARDEN=1 make -j12 test-prep Bug found with AFL (http://lcamtuf.coredump.cx/afl) Valgrind: GDB: Program received signal SIGSEGV, Segmentation fault. Hexdump of 15-byte test case: Debian 7, Kernel 3.2.65-1+deb7u1 x86_64, GCC 4.9.2, libc 2.13-38+deb7u7 |
From @geeknik |
From @hvdsThe test case can be simplified further to: % ./miniperl -e '*_ = "" for 0 .. 1' This looks to be another stack refcounting issue, similar to the various other cases where we overwrite a glob part of which is in use. Hugo |
The RT System itself - Status changed from 'new' to 'open' |
From @tonycozOn Sat Mar 07 01:12:20 2015, hv wrote:
This doesn't involve anything on the stack though. In this case we have a GV * in the loop context, and we fetch a direct entry to its SV * member, which the *_ = "" has nulled out. The following is probably the simplest fix: Inline Patchdiff --git a/cop.h b/cop.h
index d36d189..98f3192 100644
--- a/cop.h
+++ b/cop.h
@@ -773,7 +773,7 @@ struct block_loop {
? (CxPADLOOP(c) \
? CxITERVAR_PADSV(c) \
: isGV((c)->blk_loop.itervar_u.gv) \
- ? &GvSV((c)->blk_loop.itervar_u.gv) \
+ ? &GvSVn((c)->blk_loop.itervar_u.gv) \
: (SV **)&(c)->blk_loop.itervar_u.gv) \
: (SV**)NULL)
Inline Patchdiff --git a/pp_hot.c b/pp_hot.c
index e866841..fe48dfe 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2558,7 +2558,7 @@ PP(pp_iter)
RETPUSHNO;
oldsv = *itersvp;
- if (LIKELY(SvREFCNT(oldsv) == 1 && !SvMAGICAL(oldsv))) {
+ if (LIKELY(oldsv && SvREFCNT(oldsv) == 1 && !SvMAGICAL(oldsv))) {
/* safe to reuse old SV */
sv_setsv(oldsv, cur);
}
@@ -2568,7 +2568,7 @@ PP(pp_iter)
* completely new SV for closures/references to work as
* they used to */
*itersvp = newSVsv(cur);
- SvREFCNT_dec_NN(oldsv);
+ SvREFCNT_dec(oldsv);
}
if (strEQ(SvPVX_const(cur), max))
sv_setiv(cur, 0); /* terminate next time */
@@ -2585,7 +2585,7 @@ PP(pp_iter)
oldsv = *itersvp;
/* don't risk potential race */
- if (LIKELY(SvREFCNT(oldsv) == 1 && !SvMAGICAL(oldsv))) {
+ if (LIKELY(oldsv && SvREFCNT(oldsv) == 1 && !SvMAGICAL(oldsv))) {
/* safe to reuse old SV */
sv_setiv(oldsv, cur);
}
@@ -2595,7 +2595,7 @@ PP(pp_iter)
* completely new SV for closures/references to work as they
* used to */
*itersvp = newSViv(cur);
- SvREFCNT_dec_NN(oldsv);
+ SvREFCNT_dec(oldsv);
}
if (UNLIKELY(cur == IV_MAX)) {
Tony |
From @iabynOn Mon, Oct 19, 2015 at 04:48:57PM -0700, Tony Cook via RT wrote:
Note that I have a private branch that *heavily* reworks cop.h and -- |
From @iabynOn Tue, Oct 20, 2015 at 01:32:04PM +0100, Dave Mitchell wrote:
I've now applied your second variant to my private context branch, which -- |
From @iabynOn Fri, Dec 18, 2015 at 03:34:45PM +0000, Dave Mitchell wrote:
And now merged into blead, as -- |
@iabyn - Status changed from 'open' to 'pending release' |
From @khwilliamsonThank you for submitting this report. You have helped make Perl better. Perl 5.24.0 may be downloaded via https://metacpan.org/release/RJBS/perl-5.24.0 |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#123994 (status was 'resolved')
Searchable as RT123994$
The text was updated successfully, but these errors were encountered: