Skip to content
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

Attempt to free unreferenced scalar: SV... #9389

Closed
p5pRT opened this issue Jun 21, 2008 · 7 comments
Closed

Attempt to free unreferenced scalar: SV... #9389

p5pRT opened this issue Jun 21, 2008 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 21, 2008

Migrated from rt.perl.org#56202 (status was 'resolved')

Searchable as RT56202$

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2008

From cappella@glacier.mikecappella.com

Created by cappella@glacier.mikecappella.com

I'm hitting what appears to be a bug in creating an array of qr's​:

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 resulting 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 Info

Flags:
    category=core
    severity=medium

Site configuration information for perl v5.8.8:

Configured by cappella at Sun Jun  1 18:40:11 PDT 2008.

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 (generic.mp) #0: sat sep 1 15:50:48 pdt 2007 builds@wb42:homebuildsabnetbsd-4-0-rc1i386200709011431z-objhomebuildsabnetbsd-4-0-rc1srcsysarchi386compilegeneric.mp i386 '
    config_args='-sde -Darchname=i386-netbsd -Dcc=cc -Doptimize=-O2 -pthread -I/usr/include -Ui_malloc -Uusemymalloc -Uinstallusrbinperl -Dinstallstyle=lib/perl5 -Dprefix=/usr/pkg -Dsiteprefix=/usr/pkg -Dvendorprefix=/usr/pkg -Dscriptdir=/usr/pkg/lib/perl5/bin -Dsitescript=/usr/pkg/lib/perl5/site_perl/bin -Dvendorscript=/usr/pkg/lib/perl5/vendor_perl/bin -Dsitebin=/usr/pkg/lib/perl5/site_perl/bin -Dvendorbin=/usr/pkg/lib/perl5/vendor_perl/bin -Dprivlib=/usr/pkg/lib/perl5/5.8.0 -Dsitelib=/usr/pkg/lib/perl5/site_perl/5.8.0 -Dvendorlib=/usr/pkg/lib/perl5/vendor_perl/5.8.0 -Dsitelib_stem=/usr/pkg/lib/perl5/site_perl -Dvendorlib_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 -Dman3ext=3 -Dman3dir=/usr/pkg/lib/perl5/man/man3 -Dsiteman3dir=/usr/pkg/lib/perl5/site_perl/man/man3 -Dvendorman3dir=/usr/pkg/lib/perl5/vendor_perl/man/man3 -Duses
 hrplib -Daphostname=/bin/hostname -Dln=/bin/ln -Dsed=/usr/bin/sed -Dsh=/bin/sh -Dissymlink=test -h -Dperl5=false -Duseithreads -Dlibswanted=m crypt '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=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 20061125)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    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-archive -shared  -L/usr/pkg/lib'

Locally applied patches:
    


@INC for perl v5.8.8:
    /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
    .


Environment for perl v5.8.8:
    HOME=/home/cappella
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/cappella/bin:/usr/local/bin:/usr/local/sbin:/usr/pkg/bin:/usr/pkg/sbin:/sbin:/bin:/usr/sbin:/usr/bin
    PERL_BADLANG (unset)
    SHELL=/usr/pkg/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2008

From p5p@spam.wizbit.be

On Sat Jun 21 14​:59​:59 2008, cappella@​glacier.mikecappella.com wrote​:

This is a bug report for perl from cappella@​glacier.mikecappella.com,
generated with the help of perlbug 1.35 running under perl v5.8.8.

-----------------------------------------------------------------
[Please enter your report here]

I'm hitting what appears to be a bug in creating an array of qr's​:

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 resulting
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).

On perl-5.8.8 I see empty elements for index 127-131.
On perl-5.8.9-tobe, perl-5.10.0 and perl-blead I see no empty elements.

If I add​: use strict in the code then I do get *** glibc detected ***
double free or corruption (!prev)​: 0x08135f00 *** with 5.8.8. (5.8.9-
tobe works fine)

Also​: the /o modifier in your regexes does nothing.
(It is best never to use /o.)

If I use​:

my @​ignore_list = (
  qr/ all milters$/, # 0
  ...
  qr/^write to [a-fA-F\d]{8}/, # 126
);
 
push @​ignore_list, (
  qr/^xsasl_cyrus_server_/, # 127
  ...
  qr/socket​: wanted attribute​: /, # 131
);

Then I do get the expected output.

Can you try this work around and confirm that the error goes away?

Kind regards,

Bram

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2008

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jun 22, 2008

From mike-perl@cappella.us

Bram via RT wrote​:

On Sat Jun 21 14​:59​:59 2008, cappella (at) glacier.mikecappella.com wrote​:

This is a bug report for perl from cappella (at) glacier.mikecappella.com,
generated with the help of perlbug 1.35 running under perl v5.8.8.

-----------------------------------------------------------------
[Please enter your report here]

I'm hitting what appears to be a bug in creating an array of qr's​:

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 resulting
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).

On perl-5.8.8 I see empty elements for index 127-131.
On perl-5.8.9-tobe, perl-5.10.0 and perl-blead I see no empty elements.

If I add​: use strict in the code then I do get *** glibc detected ***
double free or corruption (!prev)​: 0x08135f00 *** with 5.8.8. (5.8.9-
tobe works fine)

My full code uses strict mode. This was a code segment. I don't recall
seeing the glibc double free message, but it might have been there.

Also​: the /o modifier in your regexes does nothing.
(It is best never to use /o.)

I have a number of patterns with variable interpolation - the /o was for
ease in identifying those which have variable interpolation with
unchanging variables, where it is safe to optimize.

I'm curious - why is it best to never use /o ? Even with variable
interpolation into patterns ?

If I use​:

my @​ignore_list = (
qr/ all milters$/, # 0
...
qr/^write to [a-fA-F\d]{8}/, # 126
);

It appears you've made two changes to the test case​: removing /o and
changing the number of patterns is what I see. I tried removing the /o,
but that had no affect. When I removed seemingly random numbers of the
patterns, the bug would not show itself. The number of patterns plays
a role somehow. In my experience, this type of problem usually means a
stack, heap or buffer overflow problem, but I'm not familiar at all with
perl internals.

On my older system i686 linux system, I get a simple and immediate "Out
of memory!" message; no "Attempt to free unrefernced scalar..."

push @​ignore_list, (
qr/^xsasl_cyrus_server_/, # 127
...
qr/socket​: wanted attribute​: /, # 131
);

Then I do get the expected output.

Can you try this work around and confirm that the error goes away?

This is the workaround I am using essentially, but with multiple push()
calls, vs one with a long list of arguments. I didn't want to tempt
fate, and wasted enough time trying to figure out what was going on with
this bug.

Thanks for the fast follow-up !
Mike

Kind regards,

Bram

@p5pRT
Copy link
Author

p5pRT commented Aug 2, 2008

From p5p@spam.wizbit.be

Also​: the /o modifier in your regexes does nothing.
(It is best never to use /o.)

I have a number of patterns with variable interpolation - the /o was
for
ease in identifying those which have variable interpolation with
unchanging variables, where it is safe to optimize.

I'm curious - why is it best to never use /o ? Even with variable
interpolation into patterns ?

I advice against using /o because it can make the code less maintable (as
in, more confusing) and because it usually has no influence.

(And the times it does have an influence it can come back to haunt you. Seen
enough bug repots about it.)

When can /o go wrong?
For example, if you also use the empty pattern (maybe intended, maybe not).

From a bug report​:

#!/usr/bin/perl -l
for ("bar", "", "foo") {
  "bar" =~ m/^bar$/o;
  if ($_ =~ /$_/) {
  print "MATCH​: $_";
  }
}
__END__
Output​:

MATCH​: bar

Most people code expect to see the output​:
MATCH​: bar
MATCH​: foo

What is happening is that the 'compile only once' flag of m/^bar$/o is
copied to the $_ =~ /$_/ regex. ($_ is empty so the last successful pattern
is re-used. Turning it into $_ =~ /^bar$/.)

If you really intend to evaluate some variable only once then it is my advice
to use qr// and the variable you want.

That is instead of​:

#!/usr/bin/perl -l
my $i = 5;
for (1 .. 3) {
  if ("foo5" =~ m/^foo$i$/o) {
  print "ok"
  }
  $i++;
}

I would advice to write​:

#!/usr/bin/perl -l
my $i = 5;
my $re = qr/^foo$i$/;
for (1 .. 3) {
  if ("foo5" =~ $re) {
  print "ok"
  }
  $i++;
}

This (IMHO) makes it somewhat clearer what the intend is.

Kind regards,

Bram

@p5pRT
Copy link
Author

p5pRT commented Aug 2, 2008

From p5p@spam.wizbit.be

A binary search revealed that this was fixed with change 30211.

http​://public.activestate.com/cgi-bin/perlbrowse/p/30211
Change 30211 by rgs@​marais on 2007/02/11 16​:20​:15

  Subject​: [perl #41484] qr// stack bug
  From​: knew-p5p@​pimb.org (via RT) <perlbug-followup@​perl.org>
  Date​: Sat, 10 Feb 2007 19​:32​:17 -0800
  Message-ID​: <rt-3.6.HEAD-14573-1171164736-117.41484-75-
0@​perl.org>

@p5pRT
Copy link
Author

p5pRT commented Aug 2, 2008

p5p@spam.wizbit.be - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant