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

[perl #133072] Double macro argument evaluation in S_init_main_stash

Thread Next
From:
Pip Cet
Date:
April 6, 2018 03:35
Subject:
[perl #133072] Double macro argument evaluation in S_init_main_stash
Message ID:
rt-4.0.24-19092-1522985739-1544.133072-75-0@perl.org
# New Ticket Created by  Pip Cet 
# Please include the string:  [perl #133072]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=133072 >


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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About