Closed p5pRT closed 13 years ago
Trim dead code in do_kv.
A small piece of code in do_kv has three bugs:
- TARG could have been returned as an lvalue\, so its refcount could be greater than 1\, resulting in data getting clobbered. (See RT#20933 for previously fixed occurrence of this bug).
- LvTARG is refcounted\, so it's buggy to just NULL it.
- TARG is returned without being initialised.
The first two bugs disappeared recently when we stopped putting the lvalues in TARG for that op. The third remains.
However\, it seems that code is never called. It can only be called by putting NULL (not undef) on the Perl stack. I don't see how that's possible here. The test suite never reaches that code\, so it seems it's just dead code.
- Eric Brine
On Tue\, Aug 17\, 2010 at 08:15:35PM -0700\, Eric Brine wrote:
# New Ticket Created by "Eric Brine" # Please include the string: [perl #77290] # in the subject line of all future correspondence about this issue. # \<URL: http://rt.perl.org/rt3/Ticket/Display.html?id=77290 >
Trim dead code in do_kv.
A small piece of code in do_kv has three bugs:
- TARG could have been returned as an lvalue\, so its refcount could be greater than 1\, resulting in data getting clobbered. (See RT#20933 for previously fixed occurrence of this bug).
- LvTARG is refcounted\, so it's buggy to just NULL it.
- TARG is returned without being initialised.
The first two bugs disappeared recently when we stopped putting the lvalues in TARG for that op. The third remains.
Do you happen to (easily) know the commit that changed lvalues into TARG?
However\, it seems that code is never called. It can only be called by putting NULL (not undef) on the Perl stack. I don't see how that's possible here. The test suite never reaches that code\, so it seems it's just dead code.
I *had* assumed that it was not valid to put NULL on the Perl stack. However\, it can happen for invalid glob lookups - the GV argument popped by pp_readdir in this code is NULL:
$ ./perl -Ilib -MO=Concise -e '$x = "."; readdir($x)' a \<@> leave[1 ref] vKP/REFC ->(end) 1 \<0> enter ->2 2 \<;> nextstate(main 1 -e:1) v:{ ->3 5 \<2> sassign vKS/2 ->6 3 \<$> const(PV ".") s ->4 - \<1> ex-rv2sv sKRM*/1 ->5 4 \<$> gvsv(*x) s ->5 6 \<;> nextstate(main 1 -e:1) v:{ ->7 9 \<1> readdir vK/1 ->a 8 \<1> rv2gv sK*/1 ->9 - \<1> ex-rv2sv sK/1 ->8 7 \<$> gvsv(*x) s ->8 -e syntax OK
$ ./perl -Ds -e '$x = "."; readdir($x)'
EXECUTING...
=>
=>
=>
=> PV("."\0)
=> PV("."\0) UNDEF
=> PV("."\0)
=>
=> PV("."\0)
=> VOID
Bad symbol for dirhandle at -e line 1.
That's NULL for a GV. I don't know if there's any way to get NULL on the stack for an HV.
Nicholas Clark
The RT System itself - Status changed from 'new' to 'open'
On Wed\, Aug 18\, 2010 at 5:34 AM\, Nicholas Clark \nick@​ccl4\.org wrote:
The first two bugs disappeared recently when we stopped putting the lvalues in TARG for that op. The third remains.
Do you happen to (easily) know the commit that changed lvalues into TARG?
Into TARG? I think lvalue keys always used TARG. http://perl5.git.perl.org/perl.git/commitdiff/85581909df34d9ffca6c85cafeb2595c4cb89ffb
Away from TARG? RT#67838 http://perl5.git.perl.org/perl.git/commit/e2fe06dd0f4d62a54d7bbc2a1f42dae0dd6bf19e http://perl5.git.perl.org/perl.git/commit/213f7ada530c1a4c4148622ba78577585f8ab9d0 http://perl5.git.perl.org/perl.git/commit/0607bed5b8805b56401c29fc8c6d0f3737d5353f http://perl5.git.perl.org/perl.git/commit/2154eca77956ce145743765bea9ce269e6227984
However\, it seems that code is never called. It can only be called by putting NULL (not undef) on the Perl stack. I don't see how that's possible here. The test suite never reaches that code\, so it seems it's just dead code.
I *had* assumed that it was not valid to put NULL on the Perl stack. However\, it can happen for invalid glob lookups - the GV argument popped by pp_readdir in this code is NULL:
Should that be changed?
- Eric Brine
On Wed Aug 18 09:02:31 2010\, ikegami@adaelis.com wrote:
On Wed\, Aug 18\, 2010 at 5:34 AM\, Nicholas Clark \nick@​ccl4\.org wrote:
The first two bugs disappeared recently when we stopped putting the lvalues in TARG for that op. The third remains.
Do you happen to (easily) know the commit that changed lvalues into TARG?
Into TARG? I think lvalue keys always used TARG.
http://perl5.git.perl.org/perl.git/commitdiff/85581909df34d9ffca6c85cafeb2595c4cb89ffb
Away from TARG? RT#67838
http://perl5.git.perl.org/perl.git/commit/e2fe06dd0f4d62a54d7bbc2a1f42dae0dd6bf19e
http://perl5.git.perl.org/perl.git/commit/213f7ada530c1a4c4148622ba78577585f8ab9d0
http://perl5.git.perl.org/perl.git/commit/0607bed5b8805b56401c29fc8c6d0f3737d5353f
http://perl5.git.perl.org/perl.git/commit/2154eca77956ce145743765bea9ce269e6227984
However\, it seems that code is never called. It can only be called by putting NULL (not undef) on the Perl stack. I don't see how that's possible here. The test suite never reaches that code\, so it seems it's just dead code.
I *had* assumed that it was not valid to put NULL on the Perl stack. However\, it can happen for invalid glob lookups - the GV argument popped by pp_readdir in this code is NULL:
As I noted elsewhere\, it happened by accident in commit 7a5fd60d4c.
Should that be changed?
It has been\, with commit 99fc7eca40.
So I think your patch is safe to apply\, and it has been applied as 73ff03e.
(I’m actually going to make some changes that will put nulls on the stack on purpose\, but they will not affect keys and values.)
@cpansprout - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#77290 (status was 'resolved')
Searchable as RT77290$