Subject: | dbih_imp_sv use after free in global destruction |
asan still reports this (see below)
with 1.616 I fixed it with:
--- ./DBI.xs~ 2010-12-21 16:59:27.000000000 -0600
+++ ./DBI.xs 2011-12-08 14:16:45.282057663 -0600
@@ -1331,7 +1331,6 @@
/* Use DBI magic on inner handle to carry handle attributes
*/
sv_magic(SvRV(h), dbih_imp_sv, DBI_MAGIC, Nullch, 0);
- SvREFCNT_dec(dbih_imp_sv); /* since sv_magic() incremented it
*/
SvRMAGICAL_on(SvRV(h)); /* so DBI magic gets sv_clear'd ok
*/
DBI_SET_LAST_HANDLE(h);
But this not work anymore. I suggest to check for the status of
${^GLOBAL_PHASE} in global destruction.
gdb --args /usr/local/bin/perl5.15.8d-nt-asan -Mblib t/11fetch.t
=================================================================
==28536== ERROR: AddressSanitizer heap-use-after-free on address
0x7f22abf87084 at pc 0x7f22aaa169a4 bp 0x7fff4808af70 sp 0x7fff4808af68
READ of size 4 at 0x7f22abf87084 thread T0
#2 0x00007ffff29119a4 in XS_DBI_dispatch (cv=<value optimized
Show quoted text
out>) at DBI.xs:3387
#3 0x00007ffff708dc52 in Perl_pp_entersub () at pp_hot.c:2778
#4 0x00007ffff67ae38d in Perl_call_sv (sv=0x7ffff4d47ec0,
flags=45) at perl.c:2699
#5 0x00007ffff72354f0 in S_curse (sv=<value optimized out>,
check_refcnt=Unhandled dwarf expression opcode 0x0) at sv.c:6377
#6 0x00007ffff7222b9f in Perl_sv_clear (orig_sv=<value optimized
Show quoted textout>) at sv.c:6042
#7 0x00007ffff70b24c5 in Perl_sv_free2 (sv=<value optimized out>)
at sv.c:6509
#8 0x00007ffff70a7e49 in do_clean_objs (ref=<value optimized out>)
at sv.c:478
#9 0x00007ffff70a57b3 in S_visit (f=<value optimized out>, flags=
<value optimized out>, mask=<value optimized out>) at sv.c:420
#10 0x00007ffff70a6044 in Perl_sv_clean_objs () at sv.c:577
#11 0x00007ffff677facd in perl_destruct (my_perl=<value optimized
Show quoted textout>) at perl.c:776
#12 0x000000000040483a in main (argc=<value optimized out>, argv=
<value optimized out>, env=<value optimized out>) at perlmain.c:131
0x7f22abf87084 is located 4 bytes inside of 200-byte region
[0x7f22abf87080,0x7f22abf87148)
freed by thread T0 here:
previously allocated by thread T0 here:
==28536== ABORTING
Stats: 9M malloced (31M for red zones) by 140521 calls
Stats: 0M realloced by 13194 calls
Stats: 4M freed by 81460 calls
Stats: 0M really freed by 0 calls
Stats: 76M (19463 full pages) mmaped in 19 calls
mmaps by size class: 8:147447; 9:8191; 10:4095; 11:2047; 12:1024;
13:512; 14:256; 15:128; 16:64; 17:32; 18:16;
mallocs by size class: 8:138839; 9:642; 10:282; 11:81; 12:123; 13:456;
14:81; 15:3; 16:8; 17:5; 18:1;
frees by size class: 8:80811; 9:307; 10:136; 11:30; 12:18; 13:70;
14:76; 15:3; 16:7; 17:2;
rfrees by size class:
Stats: malloc large: 6 small slow: 329
Shadow byte and word:
0x1fe4557f0e10: fd
0x1fe4557f0e10: fd fd fd fd fd fd fd fd
More shadow bytes:
0x1fe4557f0df0: fa fa fa fa fa fa fa fa
0x1fe4557f0df8: fa fa fa fa fa fa fa fa
0x1fe4557f0e00: fa fa fa fa fa fa fa fa
0x1fe4557f0e08: fa fa fa fa fa fa fa fa
=>0x1fe4557f0e10: fd fd fd fd fd fd fd fd
0x1fe4557f0e18: fd fd fd fd fd fd fd fd
0x1fe4557f0e20: fd fd fd fd fd fd fd fd
0x1fe4557f0e28: fd fd fd fd fd fd fd fd
0x1fe4557f0e30: fa fa fa fa fa fa fa fa
how to repro:
http://blogs.perl.org/users/rurban/2012/03/address-sanitizer-round-
2.html
--
Reini Urban