develooper Front page | perl.perl5.porters | Postings from April 2018

[perl #133072] Double macro argument evaluation in S_init_main_stash

Thread Next
Pip Cet
April 6, 2018 03:35
[perl #133072] Double macro argument evaluation in S_init_main_stash
Message ID:
# New Ticket Created by  Pip Cet 
# Please include the string:  [perl #133072]
# in the subject line of all future correspondence about this issue. 
# <URL: >

I just came across the following problem on blead:

S_init_main_stash contains the code:

    PL_curstash = PL_defstash = (HV *)SvREFCNT_inc_simple_NN(newHV());

SvREFCNT_inc_simple_NN is defined as:

#define SvREFCNT_inc_simple_NN(sv)    (++(SvREFCNT(sv)),MUTABLE_SV(sv))

That evaluates its argument twice, which breaks with side effects.

So newHV() is called twice, one of the new HVs gets refcount 2 and
gets leaked, the other gets refcount 1 and gets stored in two
places. I suspect this is low-priority, but there might be a way to
actually destroy the stash while it is still stored in PL_defstash, in
which case it's a user-visible bug.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About