Skip Menu |
 

This queue is for tickets about the Clone CPAN distribution.

Report information
The Basics
Id: 80201
Status: resolved
Priority: 0/
Queue: Clone

People
Owner: Nobody in particular
Requestors: garu [...] cpan.org
Cc:
AdminCc:

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



Subject: [PATCH] Stop skipping SvROK handling for all magical scalars (fixes 67105 and 79730)
Download (untitled) / with headers
text/plain 845b
Hi there! upon a more thorough discussion of the bug present in 79730 with Florian Ragwitz (rafl), he was able to spot and fix the issue. As his commit message states, when using clone() on references with (non-tie, as references can't be tied) magic attached, the actual cloning of the referent has been skipped as magic_ref indicated that it should be. magic_ref appears to only have been intended to track whether or not a scalar is tied so the contents of the tied structure aren't cloned. However, it actually tracked whether or not a scalar had any kind of magic attached. That is wrong, and this commit fixes it, making t/08fieldhash.t pass in the process. Both a patch and a new test file are attached to this message. After applied, all tests still pass, plus the new one (which fails if this patch is not applied). Hope this helps!
Subject: clone_patch_2_of_2.patch
From 2ee5b4e9ad653bbf194359857c0fe61eaab0e9be Mon Sep 17 00:00:00 2001 From: Florian Ragwitz <rafl@debian.org> Date: Mon, 15 Oct 2012 09:34:07 -0300 Subject: [PATCH 2/2] Stop skipping SvROK handling for all magical scalars Previously, for references with (non-tie, as references can't be tied) magic attached, cloning of the referent has been skipped as magic_ref indicated that it should be. magic_ref appears to only have been intended to track whether or not a scalar is tied so the contents of the tied structure aren't cloned. However, it actually tracked whether or not a scalar had any kind of magic attached. That is wrong, and this commit fixes it, making t/08fieldhash.t pass in the process. --- Clone.xs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Clone.xs b/Clone.xs index df975e6..1720e53 100755 --- a/Clone.xs +++ b/Clone.xs @@ -253,13 +253,17 @@ sv_clone (SV * ref, HV* hseen, int depth) case '@': /* PERL_MAGIC_arylen_p */ continue; break; + case 'P': /* PERL_MAGIC_tied */ + case 'p': /* PERL_MAGIC_tiedelem */ + case 'q': /* PERL_MAGIC_tiedscalar */ + magic_ref++; + /* fall through */ default: obj = sv_clone(mg->mg_obj, hseen, -1); } } else { TRACEME(("magic object for type %c in NULL\n", mg->mg_type)); } - magic_ref++; /* this is plain old magic, so do the same thing */ sv_magic(clone, obj, -- 1.7.10.4
Subject: clone_patch_1_of_2.patch
From 00c24379baac4fc883cdec7c6fce12a10a02865b Mon Sep 17 00:00:00 2001 From: Florian Ragwitz <rafl@debian.org> Date: Mon, 15 Oct 2012 09:33:57 -0300 Subject: [PATCH 1/2] Add a failing tests for cloning elements of fieldhashes --- t/08fieldhash.t | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 t/08fieldhash.t diff --git a/t/08fieldhash.t b/t/08fieldhash.t new file mode 100644 index 0000000..6c5974c --- /dev/null +++ b/t/08fieldhash.t @@ -0,0 +1,19 @@ +# $Id: 07magic.t,v 1.8 2007/04/20 05:40:48 ray Exp $ + +use strict; +use warnings; +use Test::More; + +use Clone 'clone'; +use Hash::Util::FieldHash 'fieldhash'; + +fieldhash my %hash; + +my $var = {}; + +exists $hash{ \$var }; + +my $cloned = clone($var); +cmp_ok($cloned, '!=', $var); + +done_testing; -- 1.7.10.4
RT-Send-CC: rdf [...] cpan.org, flora [...] cpan.org
Download (untitled) / with headers
text/plain 1.8k
Hi Ray, this is just a follow-up on the Clone.pm issue. It's been a couple of weeks since we submitted the patch :) Since we haven't seen any updates in Clone.pm in almost 4 years now (Jan/2009) and the RT list has issues going as far back as 6 years, we were wondering if you are maybe too busy or simply lost interest in the Clone distribution altogether. If this is the case, Florian and myself gladly volunteer to step in as co-maintainers, so we are able to ship fixes like this to CPAN and keep the module as up to date as we can. You would of course still retain Clone's authorship and be able to revoke our access whenever you see fit. I've CC'd your only known email address in the off chance you're not getting the RT messages. Hopefully we'll hear from you in the next few days or so. If, for whatever reason, you're unable to reply to the RT system, please feel free to simply reply to this message via traditional email, to flora@cpan.org and garu@cpan.org. Cheers! Breno (garu) On Mon Oct 15 15:04:38 2012, GARU wrote: Show quoted text
> Hi there! > > upon a more thorough discussion of the bug present in 79730 with Florian > Ragwitz (rafl), he was able to spot and fix the issue. As his commit > message states, when using clone() on references with (non-tie, as > references can't be tied) magic attached, the actual cloning of the > referent has been skipped as magic_ref indicated that it should be. > > magic_ref appears to only have been intended to track whether or not a > scalar is tied so the contents of the tied structure aren't cloned. > However, it actually tracked whether or not a scalar had any kind of > magic attached. That is wrong, and this commit fixes it, making > t/08fieldhash.t pass in the process. > > Both a patch and a new test file are attached to this message. After > applied, all tests still pass, plus the new one (which fails if this > patch is not applied). > > Hope this helps!
Fixed in 0.32!


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.