develooper Front page | perl.perl5.porters | Postings from May 2015

[perl #124181] Tests spew unreferenced scalar warnings

Thread Previous
From:
Hugo van der Sanden via RT
Date:
May 9, 2015 11:54
Subject:
[perl #124181] Tests spew unreferenced scalar warnings
Message ID:
rt-4.0.18-11626-1431172433-1526.124181-15-0@perl.org
I'm able to reproduce this. Here are cut-down versions of the 4 cases:

% PERL_DESTRUCT_LEVEL=2 ./perl -e '@INC = "lib"; { package XS::Typemap; require XSLoader; XSLoader::load() } XS::Typemap::T_STDIO_open("stdio.tmp")'
Attempt to free unreferenced scalar: SV 0x1d1b6a8 during global destruction.
% PERL_DESTRUCT_LEVEL=2 ./perl -e '@INC = "lib"; { package XS::Typemap; require XSLoader; XSLoader::load() } $buf = ""; open $fh, "+<", \$buf; XS::Typemap::T_INOUT($fh); close $fh'
Attempt to free unreferenced scalar: SV 0x2844760 during global destruction.
% PERL_DESTRUCT_LEVEL=2 ./perl -e '@INC = "lib"; { package XS::Typemap; require XSLoader; XSLoader::load() } $buf = ""; open $fh, "<", \$buf; XS::Typemap::T_IN($fh); close $fh'
Attempt to free unreferenced scalar: SV 0x2748628 during global destruction.
% PERL_DESTRUCT_LEVEL=2 ./perl -e '@INC = "lib"; { package XS::Typemap; require XSLoader; XSLoader::load() } $buf = ""; open $fh, "+<", \$buf; XS::Typemap::T_OUT($fh); close $fh'
Attempt to free unreferenced scalar: SV 0xa1c7a8 during global destruction.
% 

% ./perl -Ilib -V
Summary of my perl5 (revision 5 version 22 subversion 0) configuration:
  Commit id: 416c06fc852c00a948ade2fd39e7bf1b9f00ca9d
  Platform:
    osname=linux, osvers=3.13.0-37-generic, archname=x86_64-linux
    uname='linux shad2 3.13.0-37-generic #64-ubuntu smp mon sep 22 21:28:38 utc 2014 x86_64 x86_64 x86_64 gnulinux '
    config_args='-des -Dcc=gcc -Dprefix=/opt/blead-d -Doptimize=-g -O6 -DDEBUGGING -Dusedevel -Uversiononly'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-g -O6',
    cppflags='-fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.8.2', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
    libs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.19.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.19'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -g -O6 -L/usr/local/lib -fstack-protector'


Characteristics of this binary (from libperl): 
  Compile-time options: DEBUGGING HAS_TIMES PERLIO_LAYERS
                        PERL_DONT_CREATE_GVSV
                        PERL_HASH_FUNC_ONE_AT_A_TIME_HARD PERL_MALLOC_WRAP
                        PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV
                        PERL_USE_DEVEL USE_64_BIT_ALL USE_64_BIT_INT
                        USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE
                        USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_LOCALE_TIME
                        USE_PERLIO USE_PERL_ATOF
  Locally applied patches:
        RC0
  Built under linux
  Compiled at May  9 2015 09:35:23
  %ENV:
    PERL_TEST_MEMORY="8"
  @INC:
    lib
    /opt/blead-d/lib/perl5/site_perl/5.22.0/x86_64-linux
    /opt/blead-d/lib/perl5/site_perl/5.22.0
    /opt/blead-d/lib/perl5/5.22.0/x86_64-linux
    /opt/blead-d/lib/perl5/5.22.0
    /opt/blead-d/lib/perl5/site_perl/5.21.9
    /opt/blead-d/lib/perl5/site_perl
    .
% 

Not sure I know how to diagnose this, but here's a stack trace for the complaint on the first example:

PERL_DESTRUCT_LEVEL=2 gdb ./perl
GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./perl...done.
(gdb) break sv.c:7069
Breakpoint 1 at 0x528811: file sv.c, line 7069.
(gdb) run -e '@INC = "lib"; { package XS::Typemap; require XSLoader; XSLoader::load() } XS::Typemap::T_STDIO_open("stdio.tmp")'
Starting program: /src/package/lang/perl/gitperl/perl -e '@INC = "lib"; { package XS::Typemap; require XSLoader; XSLoader::load() } XS::Typemap::T_STDIO_open("stdio.tmp")'
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, Perl_sv_free2 (sv=sv@entry=0x9815b0, rc=rc@entry=0) at sv.c:7069
7069            Perl_warner(aTHX_ packWARN(WARN_INTERNAL),
(gdb) where
#0  Perl_sv_free2 (sv=sv@entry=0x9815b0, rc=rc@entry=0) at sv.c:7069
#1  0x0000000000527d9a in S_SvREFCNT_dec (sv=0x9815b0) at inline.h:166
#2  Perl_sv_free (sv=0x9815b0) at sv.c:7002
#3  Perl_sv_clear (orig_sv=orig_sv@entry=0x9536b0) at sv.c:6846
#4  0x00000000005286e1 in Perl_sv_free2 (sv=sv@entry=0x9536b0, 
    rc=<optimized out>) at sv.c:7033
#5  0x000000000045c20e in S_SvREFCNT_dec (sv=0x9536b0) at inline.h:166
#6  Perl_gp_free (gv=gv@entry=0x953698) at gv.c:2547
#7  0x00000000005280ba in Perl_sv_clear (orig_sv=orig_sv@entry=0x953680)
    at sv.c:6684
#8  0x00000000005286e1 in Perl_sv_free2 (sv=sv@entry=0x953680, 
    rc=<optimized out>) at sv.c:7033
#9  0x000000000045c20e in S_SvREFCNT_dec (sv=0x953680) at inline.h:166
#10 Perl_gp_free (gv=gv@entry=0x953668) at gv.c:2547
#11 0x00000000005280ba in Perl_sv_clear (orig_sv=orig_sv@entry=0x935fe0)
    at sv.c:6684
#12 0x00000000005286e1 in Perl_sv_free2 (sv=sv@entry=0x935fe0, 
    rc=<optimized out>) at sv.c:7033
#13 0x0000000000456715 in S_SvREFCNT_dec (sv=0x935fe0) at inline.h:166
#14 perl_destruct (my_perl=<optimized out>) at perl.c:1089
#15 0x0000000000420ab4 in main (argc=3, argv=0x7fffffffe5c8, 
    env=0x7fffffffe5e8) at perlmain.c:127
(gdb) p *sv
$1 = {sv_any = 0x9362b0, sv_refcnt = 0, sv_flags = 255, sv_u = {svu_pv = 0x0, 
    svu_iv = 0, svu_uv = 0, svu_nv = 0, svu_rv = 0x0, svu_rx = 0x0, 
    svu_array = 0x0, svu_hash = 0x0, svu_gp = 0x0, svu_fp = 0x0}}
(gdb) p /x *(SV*)0x9536b0
$2 = {sv_any = 0x93bf00, sv_refcnt = 0x0, sv_flags = 0x3200000c, sv_u = {
    svu_pv = 0x96dc90, svu_iv = 0x96dc90, svu_uv = 0x96dc90, svu_nv = 0x0, 
    svu_rv = 0x96dc90, svu_rx = 0x96dc90, svu_array = 0x96dc90, 
    svu_hash = 0x96dc90, svu_gp = 0x96dc90, svu_fp = 0x96dc90}}
(gdb) p *(XPVHV*)0x93bf00 
$3 = {xmg_stash = 0x0, xmg_u = {xmg_magic = 0x0, xmg_hash_index = 0}, 
  xhv_keys = 29, xhv_max = 63}


I'm not sure how to determine what's actually being freed here, suggestions welcome.

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=124181

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About