Re: after upgrade: glibc detected *** /usr/bin/perl: double free or corruption

Peter Daum <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.ldap,gmane.comp.lang.perl.beginners
Message-ID <[email protected]>
Graham Barr wrote:
[...]
In your first statement

   ($self->{prog_name}= $0) =~ s|^.*/([^/]+)$|$1|;

you are calling s/// on the hash element. In the second

   $self->{prog_name}= (my $_p= $0) =~ s|^.*/([^/]+)$|$1|;

you are just setting the hash element, actually to the value "1" not the prog name.

oops ;)

> Anyway, I suspect the issue is todo with calling s/// on the element of 
> a tied hash.
> 
> See if this reproduces the issue.
> 
> {
>     package Foo;
>     use Tie::Hash;
>     use base qw(Tie::StdHash);
> 
>     sub new {
>         my $proto = shift;
>         my $inner = bless {};
>         my %outer;
>         tie %outer, __PACKAGE__, $inner;
>         bless \%outer;
>     }
> }
> 
> $self = Foo->new;
> ($self->{prog_name} = $0) =~ s|^.*/([^/]+)$|$1|;

That's it: Same thing - the program is aborted with a stack trace!
(Btw: this is happening with glibc-2.7 on Debian "lenny")

So: what's the big difference between just assigning a value and calling s/// ?
Is there anything else that shouldn't be done on a tied hash?

Regards,
                         Peter
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.