Smitty has asked for the wisdom of the Perl Monks concerning the following question:

I'm hitting what appears to be a bug : Attempt to free unreferenced scalar: SV 0x8066318, Perl interpreter: 0x804e000 at ./t.pl line 137. The code and output is below. Note the error message and the resultant output for array slices 127-131. The behavior changes when run under the debugger (no warning about Attempt to free unreferenced memory, and the output for the array is correct).

$ cat t.pl #!/usr/bin/perl my @ignore_list = ( qr/ all milters$/o, # 0 qr/(?:before|after) input_transp_cleanup: /o, # 1 qr/TLS cipher list "/o, # 2 qr/^(?:begin|end) \S+ address list$/o, # 3 qr/^(?:lookup|delete) smtp session/o, # 4 qr/^(?:reloaded|remove|looking for) session .* cache$/o, + # 5 qr/^(?:start|end) sorted recipient list$/o, # 6 qr/^Compiled against/o, # 7 qr/^Deleted: \d+ messages?$/o, # 8 qr/^Peer certi?ficate could not be verified$/o, # 9 qr/^Peer verification:/o, # 10 qr/^Read \d+ chars/o, # 11 qr/^Reusing old/o, # 12 qr/^Run-time/o, # 13 qr/^SSL_accept/o, # 14 qr/^SSL_connect:/o, # 15 qr/^Server certificate could not be verified/o, # 16 qr/^Using /o, # 17 qr/^Verified: /o, # 18 qr/^Write \d+ chars/o, # 19 qr/^[<>]+ /o, # 20 qr/^[a-f\d]{4} - <SPACES/o, # 21 qr/^[a-f\d]{4} [a-f\d]{2}/o, # 22 qr/^auto_clnt_/o, # 23 qr/^been_here: /o, # 24 qr/^begin transaction/o, # 25 qr/^cert has expired/o, # 26 qr/^certificate peer name verification failed/o, # 27 qr/^certificate verification (?:depth|failed for)/o, # 28 qr/^check_access: /o, # 29 qr/^check_domain_access: /o, # 30 qr/^check_mail_access: /o, # 31 qr/^check_table_result: /o, # 32 qr/^chroot /o, # 33 qr/^commit transaction/o, # 34 qr/^connecting to \S+ port /o, # 35 qr/^connection (?:closed|established)/o, # 36 qr/^ctable_/o, # 37 qr/^daemon started/o, # 38 qr/^delete smtp session/o, # 39 qr/^delete smtpd session/o, # 40 qr/^deliver_/o, # 41 qr/^dict_/o, # 42 qr/^discarding EHLO keywords: /o, # 43 qr/^dns_/o, # 44 qr/^done incoming queue scan$/o, # 45 qr/^event: /o, # 46 qr/^extract_addr/o, # 47 qr/^flush_send_file: queue_id/o, # 48 qr/^fsspace:/o, # 49 qr/^generic_checks:/o, # 50 qr/^get_dns_/o, # 51 qr/^idle timeout/o, # 52 qr/^inet_addr_/o, # 53 qr/^initializing the server-side TLS/o, # 54 qr/^input attribute /o, # 55 qr/^issuer=/o, # 56 qr/^looking up session/o, # 57 qr/^lookup \S+ type/o, # 58 qr/^lookup smtpd session/o, # 59 qr/^mac_parse:/o, # 60 qr/^mail_addr_find: /o, # 61 qr/^mail_flow_put: /o, # 62 qr/^maps_find: /o, # 63 qr/^master disconnect/o, # 64 qr/^master_notify:/o, # 65 qr/^match_/o, # 66 qr/^milter8/o, # 67 qr/^milter_macro_lookup/o, # 68 qr/^mynetworks:/o, # 69 qr/^name_mask:/o, # 70 qr/^nss_ldap: reconnected to LDAP/o, # 71 qr/^open smtpd TLS/o, # 72 qr/^permit_/o, # 73 qr/^pref /o, # 74 qr/^premature end-of-input (?:on|from) .* socket while reading inpu +t attribute name$/o, # 75 qr/^private\//o, # 76 qr/^process generation/o, # 77 qr/^proxymap stream/o, # 78 qr/^put smtpd session/o, # 79 qr/^qmgr_active_feed: /o, # 80 qr/^qmgr_message_alloc: /o, # 81 qr/^qmgr_message_sort: /o, # 82 qr/^qmgr_scan_start: /o, # 83 qr/^read from [a-fA-F\d]{8}/o, # 84 qr/^read smtp TLS cache entry/o, # 85 qr/^read smtpd TLS/o, # 86 qr/^rec_put: /o, # 87 qr/^reject_non_/o, # 88 qr/^reject_unauth_/o, # 89 qr/^reject_unknown_/o, # 90 qr/^reload configuration/o, # 91 qr/^reloaded session .* from \w+ cache$/o, # 92 qr/^reply: /o, # 93 qr/^request: \d/o, # 94 qr/^resolve_clnt/o, # 95 qr/^rewrite stream/o, # 96 qr/^rewrite_clnt:/o, # 97 qr/^save session/o, # 98 qr/^send attr /o, # 99 qr/^server features/o, # 100 qr/^set_eugid: /o, # 101 qr/^setting up TLS connection (?:from|to)/o, # 102 qr/^skipping event/o, # 103 qr/^skipping non-protocol event/o, # 104 qr/^smtp_addr_one: /o, # 105 qr/^smtp_connect_addr: /o, # 106 qr/^smtp_find_self: /o, # 107 qr/^smtp_get: /o, # 108 qr/^smtp_parse_destination: /o, # 109 qr/^smtp_sasl_passwd_lookup: /o, # 110 qr/^smtpd_chat_notify: /o, # 111 qr/^smtpd_check_/o, # 112 qr/^sql auxprop plugin/o, # 113 qr/^sql plugin/o, # 114 qr/^starting TLS engine$/o, # 115 qr/^statistics:/o, # 116 qr/^subject=/o, # 117 qr/^terminating on signal 15$/o, # 118 qr/^tlsmgr_cache_run_event/o, # 119 qr/^trigger_server_accept_fifo: /o, # 120 qr/^trying\.\.\. /o, # 121 qr/^verify error:num=/o, # 122 qr/^vstream_/o, # 123 qr/^watchdog_/o, # 124 qr/^write smtpd TLS/o, # 125 qr/^write to [a-fA-F\d]{8}/o, # 126 qr/^xsasl_cyrus_server_/o, # 127 qr/fingerprint=/o, # 128 qr/re-using session with untrusted certificate, look for details ea +rlier in the log$/o, # 129 qr/save session.*to smtpd cache/o, # 130 qr/socket: wanted attribute: /o, # 131 ); foreach (@ignore_list) { print "PAT[$i]: $_\n"; $i++; } $ echo 'Peer verification:' | perl ./t.pl Attempt to free unreferenced scalar: SV 0x8066318, Perl interpreter: 0 +x804e000 at ./t.pl line 137. PAT[]: (?-xism: all milters$) PAT[1]: (?-xism:(?:before|after) input_transp_cleanup: ) PAT[2]: (?-xism:TLS cipher list ") PAT[3]: (?-xism:^(?:begin|end) \S+ address list$) PAT[4]: (?-xism:^(?:lookup|delete) smtp session) PAT[5]: (?-xism:^(?:reloaded|remove|looking for) session .* cache$) PAT[6]: (?-xism:^(?:start|end) sorted recipient list$) PAT[7]: (?-xism:^Compiled against) PAT[8]: (?-xism:^Deleted: \d+ messages?$) PAT[9]: (?-xism:^Peer certi?ficate could not be verified$) PAT[10]: (?-xism:^Peer verification:) PAT[11]: (?-xism:^Read \d+ chars) PAT[12]: (?-xism:^Reusing old) PAT[13]: (?-xism:^Run-time) PAT[14]: (?-xism:^SSL_accept) PAT[15]: (?-xism:^SSL_connect:) PAT[16]: (?-xism:^Server certificate could not be verified) PAT[17]: (?-xism:^Using ) PAT[18]: (?-xism:^Verified: ) PAT[19]: (?-xism:^Write \d+ chars) PAT[20]: (?-xism:^[<>]+ ) PAT[21]: (?-xism:^[a-f\d]{4} - <SPACES) PAT[22]: (?-xism:^[a-f\d]{4} [a-f\d]{2}) PAT[23]: (?-xism:^auto_clnt_) PAT[24]: (?-xism:^been_here: ) PAT[25]: (?-xism:^begin transaction) PAT[26]: (?-xism:^cert has expired) PAT[27]: (?-xism:^certificate peer name verification failed) PAT[28]: (?-xism:^certificate verification (?:depth|failed for)) PAT[29]: (?-xism:^check_access: ) PAT[30]: (?-xism:^check_domain_access: ) PAT[31]: (?-xism:^check_mail_access: ) PAT[32]: (?-xism:^check_table_result: ) PAT[33]: (?-xism:^chroot ) PAT[34]: (?-xism:^commit transaction) PAT[35]: (?-xism:^connecting to \S+ port ) PAT[36]: (?-xism:^connection (?:closed|established)) PAT[37]: (?-xism:^ctable_) PAT[38]: (?-xism:^daemon started) PAT[39]: (?-xism:^delete smtp session) PAT[40]: (?-xism:^delete smtpd session) PAT[41]: (?-xism:^deliver_) PAT[42]: (?-xism:^dict_) PAT[43]: (?-xism:^discarding EHLO keywords: ) PAT[44]: (?-xism:^dns_) PAT[45]: (?-xism:^done incoming queue scan$) PAT[46]: (?-xism:^event: ) PAT[47]: (?-xism:^extract_addr) PAT[48]: (?-xism:^flush_send_file: queue_id) PAT[49]: (?-xism:^fsspace:) PAT[50]: (?-xism:^generic_checks:) PAT[51]: (?-xism:^get_dns_) PAT[52]: (?-xism:^idle timeout) PAT[53]: (?-xism:^inet_addr_) PAT[54]: (?-xism:^initializing the server-side TLS) PAT[55]: (?-xism:^input attribute ) PAT[56]: (?-xism:^issuer=) PAT[57]: (?-xism:^looking up session) PAT[58]: (?-xism:^lookup \S+ type) PAT[59]: (?-xism:^lookup smtpd session) PAT[60]: (?-xism:^mac_parse:) PAT[61]: (?-xism:^mail_addr_find: ) PAT[62]: (?-xism:^mail_flow_put: ) PAT[63]: (?-xism:^maps_find: ) PAT[64]: (?-xism:^master disconnect) PAT[65]: (?-xism:^master_notify:) PAT[66]: (?-xism:^match_) PAT[67]: (?-xism:^milter8) PAT[68]: (?-xism:^milter_macro_lookup) PAT[69]: (?-xism:^mynetworks:) PAT[70]: (?-xism:^name_mask:) PAT[71]: (?-xism:^nss_ldap: reconnected to LDAP) PAT[72]: (?-xism:^open smtpd TLS) PAT[73]: (?-xism:^permit_) PAT[74]: (?-xism:^pref ) PAT[75]: (?-xism:^premature end-of-input (?:on|from) .* socket while r +eading input attribute name$) PAT[76]: (?-xism:^private/) PAT[77]: (?-xism:^process generation) PAT[78]: (?-xism:^proxymap stream) PAT[79]: (?-xism:^put smtpd session) PAT[80]: (?-xism:^qmgr_active_feed: ) PAT[81]: (?-xism:^qmgr_message_alloc: ) PAT[82]: (?-xism:^qmgr_message_sort: ) PAT[83]: (?-xism:^qmgr_scan_start: ) PAT[84]: (?-xism:^read from [a-fA-F\d]{8}) PAT[85]: (?-xism:^read smtp TLS cache entry) PAT[86]: (?-xism:^read smtpd TLS) PAT[87]: (?-xism:^rec_put: ) PAT[88]: (?-xism:^reject_non_) PAT[89]: (?-xism:^reject_unauth_) PAT[90]: (?-xism:^reject_unknown_) PAT[91]: (?-xism:^reload configuration) PAT[92]: (?-xism:^reloaded session .* from \w+ cache$) PAT[93]: (?-xism:^reply: ) PAT[94]: (?-xism:^request: \d) PAT[95]: (?-xism:^resolve_clnt) PAT[96]: (?-xism:^rewrite stream) PAT[97]: (?-xism:^rewrite_clnt:) PAT[98]: (?-xism:^save session) PAT[99]: (?-xism:^send attr ) PAT[100]: (?-xism:^server features) PAT[101]: (?-xism:^set_eugid: ) PAT[102]: (?-xism:^setting up TLS connection (?:from|to)) PAT[103]: (?-xism:^skipping event) PAT[104]: (?-xism:^skipping non-protocol event) PAT[105]: (?-xism:^smtp_addr_one: ) PAT[106]: (?-xism:^smtp_connect_addr: ) PAT[107]: (?-xism:^smtp_find_self: ) PAT[108]: (?-xism:^smtp_get: ) PAT[109]: (?-xism:^smtp_parse_destination: ) PAT[110]: (?-xism:^smtp_sasl_passwd_lookup: ) PAT[111]: (?-xism:^smtpd_chat_notify: ) PAT[112]: (?-xism:^smtpd_check_) PAT[113]: (?-xism:^sql auxprop plugin) PAT[114]: (?-xism:^sql plugin) PAT[115]: (?-xism:^starting TLS engine$) PAT[116]: (?-xism:^statistics:) PAT[117]: (?-xism:^subject=) PAT[118]: (?-xism:^terminating on signal 15$) PAT[119]: (?-xism:^tlsmgr_cache_run_event) PAT[120]: (?-xism:^trigger_server_accept_fifo: ) PAT[121]: (?-xism:^trying\.\.\. ) PAT[122]: (?-xism:^verify error:num=) PAT[123]: (?-xism:^vstream_) PAT[124]: (?-xism:^watchdog_) PAT[125]: (?-xism:^write smtpd TLS) PAT[126]: (?-xism:^write to [a-fA-F\d]{8}) PAT[127]: PAT[128]: PAT[129]: PAT[130]: PAT[131]: $ perl -V Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=netbsd, osvers=4.0_rc1, archname=i386-netbsd-thread-multi uname='netbsd glacier.mikecappella.com 4.0_rc1 netbsd 4.0_rc1 (gen +eric.mp) #0: sat sep 1 15:50:48 pdt 2007 builds@wb42:homebuildsabnetb +sd-4-0-rc1i386200709011431z-objhomebuildsabnetbsd-4-0-rc1srcsysarchi3 +86compilegeneric.mp i386 ' config_args='-sde -Darchname=i386-netbsd -Dcc=cc -Doptimize=-O2 -p +thread -I/usr/include -Ui_malloc -Uusemymalloc -Uinstallusrbinperl -D +installstyle=lib/perl5 -Dprefix=/usr/pkg -Dsiteprefix=/usr/pkg -Dvend +orprefix=/usr/pkg -Dscriptdir=/usr/pkg/lib/perl5/bin -Dsitescript=/us +r/pkg/lib/perl5/site_perl/bin -Dvendorscript=/usr/pkg/lib/perl5/vendo +r_perl/bin -Dsitebin=/usr/pkg/lib/perl5/site_perl/bin -Dvendorbin=/us +r/pkg/lib/perl5/vendor_perl/bin -Dprivlib=/usr/pkg/lib/perl5/5.8.0 -D +sitelib=/usr/pkg/lib/perl5/site_perl/5.8.0 -Dvendorlib=/usr/pkg/lib/p +erl5/vendor_perl/5.8.0 -Dsitelib_stem=/usr/pkg/lib/perl5/site_perl -D +vendorlib_stem=/usr/pkg/lib/perl5/vendor_perl -Dman1ext=1 -Dman1dir=/ +usr/pkg/lib/perl5/man/man1 -Dsiteman1dir=/usr/pkg/lib/perl5/site_perl +/man/man1 -Dvendorman1dir=/usr/pkg/lib/perl5/vendor_perl/man/man1 -Dm +an3ext=3 -Dman3dir=/usr/pkg/lib/perl5/man/man3 -Dsiteman3dir=/usr/pkg +/lib/perl5/site_perl/man/man3 -Dvendorman3dir=/usr/pkg/lib/perl5/vend +or_perl/man/man3 -Duseshrplib -Daphostname=/bin/hostname -Dln=/bin/ln + -Dsed=/usr/bin/sed -Dsh=/bin/sh -Dissymlink=test -h -Dperl5=false -D +useithreads -Dlibswanted=m crypt ' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemulti +plicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-fno-strict-aliasing -pipe -Wdeclaration-after- +statement -I/usr/pkg/include', optimize='-O2 -pthread -I/usr/include', cppflags='-fno-strict-aliasing -pipe -Wdeclaration-after-statement + -I/usr/pkg/include' ccversion='', gccversion='4.1.2 20061021 prerelease (NetBSD nb3 20 +061125)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +2 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', + lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags ='-Wl,-R/usr/pkg/lib -L/usr/pkg/lib' libpth=/usr/lib /usr/pkg/lib libs=-lm -lcrypt -lpthread perllibs=-lm -lcrypt -lpthread libc=/lib/libc.so, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E +-Wl,-R/usr/pkg/lib/perl5/5.8.0/i386-netbsd-thread-multi/CORE' cccdlflags='-DPIC -fPIC ', lddlflags='-Wl,-R/usr/pkg/lib --whole-a +rchive -shared -L/usr/pkg/lib' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT USE_ITHREAD +S USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API Built under netbsd Compiled at Jun 1 2008 18:40:46 @INC: /usr/pkg/lib/perl5/site_perl/5.8.0/i386-netbsd-thread-multi /usr/pkg/lib/perl5/site_perl/5.8.0 /usr/pkg/lib/perl5/site_perl /usr/pkg/lib/perl5/vendor_perl/5.8.0/i386-netbsd-thread-multi /usr/pkg/lib/perl5/vendor_perl/5.8.0 /usr/pkg/lib/perl5/vendor_perl /usr/pkg/lib/perl5/5.8.0/i386-netbsd-thread-multi /usr/pkg/lib/perl5/5.8.0 .

Replies are listed 'Best First'.
Re: Bug: Attempt to free unreferenced scalar: SV
by ikegami (Patriarch) on Jun 21, 2008 at 21:53 UTC

    This is not the proper place to report a bug. See perlbug.

    That said, they'll probably tell you that it's been fixed in 5.10.0. I can reproduce it with 5.8.8, but not in 5.10.0.

    Unrelated, the "o" modifier is useless if you don't do interpolation, and it's quite silly to use on qr//. You're just asking for trouble by using it.

      >> Unrelated, the "o" modifier is useless if you don't do interpolation, and it's quite silly to use on qr//. You're just asking for trouble by using it.

      Understood. These are being migrated from a long if/elsif chain. The qr was just added, and I hadn't take off the /o. This stupid bug took me some time to work out. The code comes from a file with a fair number of RE's that do include variable interpolation; adding /o on all patterns was for my convenience at detecting patterns with interpolation that *didn't* use the o option.

        I've reported this as bug 56202: http://rt.perl.org/rt3/Public/Bug/Display.html?id=56202
      Thanks. Bug submitted.