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
Bug in orassign #8955
Comments
From jc@oxado.comCreated by jc@oxado.comHi all, There is a problem with the orassign (||=) implementation (though the same is probably true for other similar operators) when the right hand side expression "deletes" what is being referenced by the lvalue, and the result is used (though I'm not 100% sure about that last part). Test case: -- begin -- my @array; sub fn $array[0] = 1; my $var = $array[1] ||= fn(); -- end -- On my platform this causes a segfault during execution. In some other instances it will appear to work, but the copy SV will be bogus and will usually cause a crash later on (if it doesn't segfault right away, a Dump or Dumper on $var should crash). The fix is probably to increment the refcount on the lvalue before evaluating the right hand side (though I'm not sure this would give the right result?), or maybe to re-"evaluate" (dereference?) the lvalue after the right hand site has been evaluated (like a regular sassign would do?). Not familiar enough with perl internals to really say more... Perl Info
|
From @schwernjc@oxado.com (via RT) wrote:
Segfault confirmed with 5.8.8, 5.6.2 and 5.5.5 maint. bleadperl produces... panic: attempt to copy value 0 to a freed scalar 1804cc0 at - line 10. Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Characteristics of this binary (from libperl): |
The RT System itself - Status changed from 'new' to 'open' |
From @TuxOn Tue, 03 Jul 2007 09:31:32 -0700, "jc@oxado.com (via RT)"
Same for dor-assign: # cat xx.pl use strict; my @array; sub fn $array[0] = 1; my $var = $array[1] //= fn (); perl-5.8.8-dor # perl xx.pl perl-5.9.x-31526 # bleadperl xx.pl -- |
From @iabynOn Tue, Jul 03, 2007 at 02:01:16PM -0700, Michael G Schwern wrote:
I believe this is the 4,527th reported bug that is caused by the perl Making the stack be refcounted is something on my vague list of "things I -- |
From @cruciallyOn Jul 3, 2007, at 3:12 PM, Dave Mitchell wrote:
Is that optimisation premature? :) artur |
From blgl@hagernas.comIn article <20070703221234.GA29232@iabyn.com>, davem@iabyn.com (Dave Mitchell)
Can it even be done without breaking old XS modules? Also in the "wouldn't it be nice if" category: refcounting the inputs to /Bo Lindbergh |
From @iabynOn Wed, Jul 04, 2007 at 12:25:09PM +0200, Bo Lindbergh wrote:
I envison duplicating the stack frame for old XS - ie just before calling
That would mostly happen automatically if the stack was refcounted. The Anyway, I haven't given this much thought yet (and don't intend to yet) - -- |
From blgl@hagernas.comIn article <20070704113158.GD31152@iabyn.com>, davem@iabyn.com (Dave Mitchell)
That case seems to work fine already. The example below generates no errors { my @arr=qw(A B C D E); foreach my $el (@arr) { /Bo Lindbergh |
1 similar comment
From blgl@hagernas.comIn article <20070704113158.GD31152@iabyn.com>, davem@iabyn.com (Dave Mitchell)
That case seems to work fine already. The example below generates no errors { my @arr=qw(A B C D E); foreach my $el (@arr) { /Bo Lindbergh |
From schmorp@schmorp.deCreated by schmorp@schmorp.deorassign (and probably similar things in perl, maybe //=?) does not keep my %hash = (a => 0); $hash{a} ||= do { use Data::Dumper; warn Dumper \%hash; This will output an empty hash, which isn't a big problem in itself, but I have not found a good testcase to prove this theory, but somethign is my %hash = (a => 0); $hash{a} ||= do { warn join ":", @$array; I think the expected behaviour (on the perl level) would be that orassign $a = $b unless $a; I think this would be slow/ugly/annoying to implement. If orassign would (the problem comes uo naturally when you have some kind of cache in %hash Perl Info
|
From p5p@spam.wizbit.be$ perl-5.9.2 rt-66448.pl $ perl-5.9.3 rt-66448.pl (bisect will follow later) |
p5p@spam.wizbit.be - Status changed from 'new' to 'open' |
From p5p@spam.wizbit.be$hash{a} is undefined on every version of perl I tested. Not sure how useful this bisect is... ----Program---- $hash{a} ||= do { print join ":", @$array; ----Output of .../plLVm6w/perl-5.9.2@24615/bin/perl---- ----EOF ($?='0')---- ----EOF ($?='11')---- http://perl5.git.perl.org/perl.git/commit/ author Nicholas Clark <nick@ccl4.org> Change the IV to a union. p4raw-id: //depot/perl@24617 |
Migrated from rt.perl.org#43501 (status was 'open')
Searchable as RT43501$
The text was updated successfully, but these errors were encountered: