This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
stack push/pops: assert rpp_stack_is_rc() state
authorDavid Mitchell <davem@iabyn.com>
Fri, 17 Feb 2023 20:42:47 +0000 (20:42 +0000)
committerDavid Mitchell <davem@iabyn.com>
Wed, 16 Aug 2023 16:17:00 +0000 (17:17 +0100)
commit02e17f822a8073f2e38144146be8e6faf0e4671e
tree107f87767352e4af61bf2a8212539dcdb765b126
parent093e94b2e09673b2fc3aca4f864e66bdd66c5516
stack push/pops: assert rpp_stack_is_rc() state

On perls built with both -DPERL_RC_STACK and -DDEBUG_LEAKING_SCALARS,
add asserts to the various old-style PUSHs() etc macros and new-style
rpp_push_1() etc functions that they're operating on the right sort of
stack. In particular:

PUSHs() and POPs() should only be used on stacks where rpp_stack_is_rc()
is false, since they don't modify the reference count of the SVs they
are pushing or popping.

Conversely, rpp_push_1(), rpp_popfree_1() etc should only be used on
stacks where rpp_stack_is_rc() is true, since they modify the reference
counts of the SVs they push and pop.

On perls not compiled with PERL_RC_STACK, the rpp_ functions don't
modify the reference counts, but on such builds the rpp_stack_is_rc()
assertions in the rpp_ functions are disabled, so it all works out
still.
inline.h
pp.h