[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl5-porters
Subject:    Re: [perl #47371] 'DESTROY created new reference...' with blessed overload methods
From:       "Joshua ben Jore" <twists () gmail ! com>
Date:       2007-11-12 16:05:41
Message-ID: dc5c751d0711120805s3aa950eel25f30feebc84990a () mail ! gmail ! com
[Download RAW message or body]

On Nov 11, 2007 6:32 PM, via RT Father Chrysostomos
<perlbug-followup@perl.org> wrote:
> # New Ticket Created by  Father Chrysostomos
> # Please include the string:  [perl #47371]
> # in the subject line of all future correspondence about this issue.
> # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=47371 >
>
>
> If I pass a blessed coderef to 'overload', it causes the following
> error:
>
> $ perl -le 'use overload q/+/ => bless sub { 42 };'
> DESTROY created new reference to dead object 'main' during global
> destruction.

In Perl_sv_bless, I read this snippet. I'd then suppose that your
object going into the ->import call is failing to have SvAMAGIC_on set
because it is happening too early. The stash won't have

    if (Gv_AMG(stash))
        SvAMAGIC_on(sv);
    else
        (void)SvAMAGIC_off(sv);

I haven't read enough of Perl_GV_AMupdate in gv.c to know what this
matters to but the fix for you is pretty obvious. Don't bless into
your package until you've done the overload call.

Josh
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic