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
[PATCH blead] Re: Overload Segfaulting #9378
Comments
From rick@bort.caOn Jun 12 2008, Craig A. Berry wrote:
This is because RvDEEPCP does this SvRV_set(rv, AMG_CALLun(rv,copy)); and AMG_CALLun is returning NULL. It returns NULL because there is no Anyway, patch attached. -- |
From rick@bort.caov_copy.patchdiff -pruN perl-current/lib/overload.pm perl-current-dev/lib/overload.pm
--- perl-current/lib/overload.pm 2007-04-25 11:19:52.000000000 -0400
+++ perl-current-dev/lib/overload.pm 2008-06-14 14:39:40.000000000 -0400
@@ -588,7 +588,8 @@ appear as lvalue when the above code is
If the copy constructor is required during the execution of some mutator,
but a method for C<'='> was not specified, it can be autogenerated as a
-string copy if the object is a plain scalar.
+string copy if the object is a plain scalar or a simple assignment if it
+is not.
=over 5
@@ -675,7 +676,8 @@ C<E<lt>=E<gt>> or C<cmp>:
=item I<Copy operator>
can be expressed in terms of an assignment to the dereferenced value, if this
-value is a scalar and not a reference.
+value is a scalar and not a reference, or simply a reference assignment
+otherwise.
=back
diff -pruN perl-current/lib/overload.t perl-current-dev/lib/overload.t
--- perl-current/lib/overload.t 2008-01-06 15:36:14.000000000 -0500
+++ perl-current-dev/lib/overload.t 2008-06-14 13:06:08.000000000 -0400
@@ -47,7 +47,7 @@ sub numify { 0 + "${$_[0]}" } # Not need
package main;
$| = 1;
-use Test::More tests => 556;
+use Test::More tests => 558;
$a = new Oscalar "087";
@@ -1427,4 +1427,20 @@ foreach my $op (qw(<=> == != < <= > >=))
is($aref**1, $num_val, 'exponentiation of ref');
}
+{
+ package CopyConstructorFallback;
+ use overload
+ '++' => sub { "$_[0]"; $_[0] },
+ fallback => 1;
+ sub new { bless {} => shift }
+
+ package main;
+
+ my $o = CopyConstructorFallback->new;
+ my $x = $o++; # would segfault
+ my $y = ++$o;
+ is($x, $o, "copy constructor falls back to assignment (postinc)");
+ is($y, $o, "copy constructor falls back to assignment (preinc)");
+}
+
# EOF
diff -pruN perl-current/pp.h perl-current-dev/pp.h
--- perl-current/pp.h 2008-01-04 15:32:34.000000000 -0500
+++ perl-current-dev/pp.h 2008-06-14 13:40:38.000000000 -0400
@@ -487,9 +487,9 @@ Does not use C<TARG>. See also C<XPUSHu
/* SV* ref causes confusion with the member variable
changed SV* ref to SV* tmpRef */
-#define RvDEEPCP(rv) STMT_START { SV* tmpRef=SvRV(rv); \
- if (SvREFCNT(tmpRef)>1) { \
- SvRV_set(rv, AMG_CALLun(rv,copy)); \
+#define RvDEEPCP(rv) STMT_START { SV* tmpRef=SvRV(rv); SV* rv_copy; \
+ if (SvREFCNT(tmpRef)>1 && (rv_copy = AMG_CALLun(rv,copy))) { \
+ SvRV_set(rv, rv_copy); \
SvREFCNT_dec(tmpRef); \
} } STMT_END
|
From @rgs2008/6/14 via RT Rick Delaney <perlbug-followup@perl.org>:
Thanks, applied to bleadperl as change #34055. |
The RT System itself - Status changed from 'new' to 'open' |
@rgs - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#55786 (status was 'resolved')
Searchable as RT55786$
The text was updated successfully, but these errors were encountered: