Skip Menu |

This queue is for tickets about the Data-Dump-Streamer CPAN distribution.

Report information
The Basics
Id: 53700
Status: resolved
Priority: 0/
Queue: Data-Dump-Streamer

People
Owner: Nobody in particular
Requestors: bobtfish [...] bobtfish.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Data::Dump::Streamer breaks overload magic on perl <= 5.8.8
Date: Thu, 14 Jan 2010 21:14:28 +0000
To: bug-Data-Dump-Streamer [...] rt.cpan.org
From: Tomas Doran <bobtfish [...] bobtfish.net>
Hiya. Data::Dump::Streamer appears to cause the overload magic to be lost on packages it inspects in some cases on perls <= 5.8.8 Using the 'accessors_not_capturing_meta' branch of Moose (git:// git.moose.perl.org/Moose.git) then this test fails on perl 5.8.8 (and passes on 5.8.9 as this bug was fixed in perl core): http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo/MooseX-Antlers.git;a=commitdiff;h=47e1f51c0745cc717130783c8a83fe4e005d8a19 the failure occurs inside Moose when a Moose::Meta::Method instance is booleanified (Moose::Meta::Method inherits from Class::MOP::Method, which has overloading to allow you to codeify method objects - with fallback => 1 set) - the failure occurs as the class no longer has the fallback => 1 part of the overload magic. This is the same issue worked around by XS in MooseX::Role::WithOverloading, and I have verified that inserting a call to MooseX ::Role ::WithOverloading ::Meta::Role::Application::FixOverloadedRefs::reset_amagic into Moose at the relevant point causes the issue to go away. Would it be possible for you to look into this and call code similar to that implemented by reset_amagic at the appropriate points within Data::Dump::Streamer? Please feel to catch me (or rafl who came up with the fix nominated above) in #moose, #moose-dev, #p5p etc if you'd like to chat about this. Thanks in advance t0m
On Thu Jan 14 16:18:31 2010, BOBTFISH wrote: Show quoted text
> Hiya. > > Data::Dump::Streamer appears to cause the overload magic to be lost on > packages it inspects in some cases on perls <= 5.8.8 > > Using the 'accessors_not_capturing_meta' branch of Moose (git:// > git.moose.perl.org/Moose.git) then this test fails on perl 5.8.8 (and > passes on 5.8.9 as this bug was fixed in perl core): > > http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo/MooseX- > Antlers.git;a=commitdiff;h=47e1f51c0745cc717130783c8a83fe4e005d8a19 > > the failure occurs inside Moose when a Moose::Meta::Method instance is > booleanified (Moose::Meta::Method inherits from Class::MOP::Method, > which has overloading to allow you to codeify method objects - with > fallback => 1 set) - the failure occurs as the class no longer has the > fallback => 1 part of the overload magic. > > This is the same issue worked around by XS in > MooseX::Role::WithOverloading, and I have verified that inserting a > call to > MooseX > ::Role > ::WithOverloading > ::Meta::Role::Application::FixOverloadedRefs::reset_amagic into Moose > at the relevant point causes the issue to go away. > > Would it be possible for you to look into this and call code similar > to that implemented by reset_amagic at the appropriate points within > Data::Dump::Streamer? > > Please feel to catch me (or rafl who came up with the fix nominated > above) in #moose, #moose-dev, #p5p etc if you'd like to chat about > this. > > Thanks in advance > t0m >
DDS ought to be using ordinary bless() to non-magic packages, then rebless back to the original magic package. If that breaks your module, then bless() is broken.
Subject: Re: [rt.cpan.org #53700] Data::Dump::Streamer breaks overload magic on perl <= 5.8.8
Date: Sat, 3 Apr 2010 20:54:37 +0100
To: bug-Data-Dump-Streamer [...] rt.cpan.org
From: Tomas Doran <bobtfish [...] bobtfish.net>
On 3 Apr 2010, at 20:12, Joshua ben Jore via RT wrote: Show quoted text
> If that breaks your module, then bless() is broken.
Yes, yes it is. As I noted, the issue is a bug in perl <= 5.8.8, which can be worked around.. Cheers t0m
Subject: Re: [rt.cpan.org #53700] Data::Dump::Streamer breaks overload magic on perl <= 5.8.8
Date: Sun, 4 Apr 2010 08:56:53 +0100
To: bug-Data-Dump-Streamer [...] rt.cpan.org
From: Tomas Doran <bobtfish [...] bobtfish.net>
On 3 Apr 2010, at 20:12, Joshua ben Jore via RT wrote: Show quoted text
> If that breaks your module, then bless() is broken.
Yes, yes it is. As I noted, the issue is a bug in perl <= 5.8.8, which can be worked around.. Cheers t0m
On Sun Apr 04 03:51:58 2010, BOBTFISH wrote: Show quoted text
> > On 3 Apr 2010, at 20:12, Joshua ben Jore via RT wrote:
> > If that breaks your module, then bless() is broken.
> > Yes, yes it is. > > As I noted, the issue is a bug in perl <= 5.8.8, which can be worked > around.. > > Cheers > t0m >
A simpler repro like the below doesn't show the bug. I was able to repro your report by running the test you described on perl-5.8.8 however calling reset_amagic() on objects reblessed back didn't seem to correct the problem.
On Wed Feb 02 02:23:51 2011, JJORE wrote: Show quoted text
> On Sun Apr 04 03:51:58 2010, BOBTFISH wrote:
> > > > On 3 Apr 2010, at 20:12, Joshua ben Jore via RT wrote:
> > > If that breaks your module, then bless() is broken.
> > > > Yes, yes it is. > > > > As I noted, the issue is a bug in perl <= 5.8.8, which can be worked > > around.. > > > > Cheers > > t0m > >
> > A simpler repro like the below doesn't show the bug. I was able to repro > your report by running the test you described on perl-5.8.8 however > calling reset_amagic() on objects reblessed back didn't seem to correct > the problem.
package magic; use overload 'bool' => sub { 0 }, fallback => 1; sub new { my ($class) = @_; return bless {}, $class; } package main; use blib; use Data::Dump::Streamer; use Test::More tests => 4; my $o = magic->new; ok( ! $o, 'Boolifies false' ); is( "$o", '0', 'Numifies 0 because of fallback' ); diag( Dump($o) ); ok( ! $o, 'Boolifies false' ); is( "$o", '0', 'Numifies 0 because of fallback' );
Going to be testing the attached patch. It avoids using bless() on <=5.8.8.
Subject: 0001-Disable-overloading-in-a-5.8.8-safe-way-RT-53700.patch
From ae0149afbf8f77c574d35c02098f4a45dd147e09 Mon Sep 17 00:00:00 2001 From: Josh ben Jore <jjore@cpan.org> Date: Thu, 3 Feb 2011 10:23:02 -0800 Subject: [PATCH] Disable overloading in a <=5.8.8 safe way [RT #53700] --- Changes | 3 +++ lib/Data/Dump/Streamer.pm | 23 +++++++++++++++++------ lib/Data/Dump/Streamer.xs | 26 +++++++++++++++++++++++++- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/Changes b/Changes index 370e910..12c1969 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,6 @@ +... +Disable overloading in a <=5.8.8 safe way + 2.31 React to Strawberry perl $. strangeness [RT #58528] diff --git a/lib/Data/Dump/Streamer.pm b/lib/Data/Dump/Streamer.pm index 28d37b0..88f5cb2 100644 --- a/lib/Data/Dump/Streamer.pm +++ b/lib/Data/Dump/Streamer.pm @@ -206,6 +206,17 @@ EO_HU }; *lock_keys_plus=sub(\%;@){lock_ref_keys_plus(@_)}; } + if ($] <= 5.008008) { + *disable_overloading = \&SvAMAGIC_off; + *restore_overloading = \&SvAMAGIC_on; + } else { + *disable_overloading = sub ($) { + bless $_[0], 'Does::Not::Exist'; + }; + *restore_overloading = sub ($$) { + bless $_[0], $_[1]; + }; + } my %fail=map { ( $_ => 1 ) } @EXPORT_FAIL; @EXPORT_OK=grep { !$fail{$_} } @EXPORT_OK; } @@ -1526,7 +1537,7 @@ PASS:{ my $overloaded=undef; my $isoverloaded=0; if (defined $class and overload::Overloaded($item)) { - bless $item, 'Does::Not::Exist'; + disable_overloading( $item ); $overloaded= $class; $isoverloaded= 1; } @@ -1639,7 +1650,7 @@ PASS:{ if $ENV{DDS_STRICT}; } if ($isoverloaded) { - $item= bless $item, $overloaded; + restore_overloading( $item, $overloaded ); } } if ( $pass++ == 1 ) { @@ -1865,7 +1876,7 @@ sub _dump_apply_fix { #handle fix statements and GLOB's here. overload::Overloaded( $lhs ) ) { $overloaded=blessed $lhs; - bless $lhs,"Does::Not::Exist"; + disable_overloading( $lhs ); $isoverloaded=1; } foreach my $t ($self->_glob_slots('')) @@ -1926,7 +1937,7 @@ sub _dump_apply_fix { #handle fix statements and GLOB's here. } } if ($isoverloaded) { - $lhs=bless $lhs,$overloaded; + restore_overloading( $lhs, $overloaded ); } @@ -2887,7 +2898,7 @@ sub _dump_rv { } my $isoverloaded=0; if (defined $class and overload::Overloaded($item)) { - bless $item, 'Does::Not::Exist'; + disable_overloading( $item ); $overloaded= $class; $isoverloaded= 1; } @@ -2968,7 +2979,7 @@ sub _dump_rv { $self->_add_fix('bless',$idx,$overloaded); } if ($isoverloaded) { - $item=bless $item, $overloaded; + restore_overloading( $item, $overloaded ); } } if ($fix_lock && !defined($class)) { diff --git a/lib/Data/Dump/Streamer.xs b/lib/Data/Dump/Streamer.xs index 6af81df..c4ff2eb 100644 --- a/lib/Data/Dump/Streamer.xs +++ b/lib/Data/Dump/Streamer.xs @@ -107,6 +107,12 @@ my_cxinc(pTHX) # define NV double #endif +#if PERL_VERSION < 8 +# define MY_XS_AMAGIC +#endif +#if ((PERL_VERSION == 8) && (PERL_SUBVERSION <= 8)) +# define MY_XS_AMAGIC +#endif /* the following three subs are outright stolen from Data::Dumper ( Dumper.xs ) @@ -180,7 +186,6 @@ esc_q(register char *d, register char *s, register STRLEN slen) return ret; } - XS(XS_Data__Dump__Streamer_SvREADONLY); XS(XS_Data__Dump__Streamer_SvREADONLY) /* This is dangerous stuff. */ { @@ -768,6 +773,25 @@ CODE: OUTPUT: RETVAL +#ifdef MY_XS_AMAGIC + +void +SvAMAGIC_off(sv) + SV * sv +PROTOTYPE: $ +CODE: + SvAMAGIC_off(sv) + +void +SvAMAGIC_on(sv,klass) + SV * sv + SV * klass +PROTOTYPE: $ +CODE: + SvAMAGIC_off(sv) + +#endif + #ifndef NEW_REGEX_ENGINE -- 1.7.1
The solution is stranger than I imagined. Resolved in 2.32 by just fetching the () entry from the stash for every class the object ISA: https://github.com/jbenjore/Data-Dump-Streamer/commit/664c3b48e5352b6881b672d58137bdb42bde7aab
Subject: Re: [rt.cpan.org #53700] Data::Dump::Streamer breaks overload magic on perl <= 5.8.8
Date: Sat, 5 Feb 2011 12:46:03 +0100
To: bug-Data-Dump-Streamer [...] rt.cpan.org
From: demerphq <demerphq [...] gmail.com>
On 5 February 2011 05:58, Joshua ben Jore via RT <bug-Data-Dump-Streamer@rt.cpan.org> wrote: Show quoted text
>       Queue: Data-Dump-Streamer >  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=53700 > > > The solution is stranger than I imagined. Resolved in 2.32 by just > fetching the () entry from the stash for every class the object ISA: > https://github.com/jbenjore/Data-Dump-Streamer/commit/664c3b48e5352b6881b672d58137bdb42bde7aab >
thanks josh -- perl -Mre=debug -e "/just|another|perl|hacker/"
Re-closing bug.