This is a case of the blind leading the blind, so watch my step. Which I guess translates to "Listen carefully, because I shall say this only once--and probably wrong".

The effect you are describing seems to be associated with the mysteries and magic of TARGs. Those temporary stack items that are created at compile time and reused by different subs/ops and even recursive re-invocations of the same sub. They are related to the well-known optimisation that means that some sub variables don't get cleaned up when they return, but rather persist to be reused next time.

There is some scant mention of them in the sections: "Putting a C value on Perl stack", "Scratchpads" & "Scratchpads and recursion" of Perlguts, but it is less than clear. At least to me when I encountered this a couple of years ago.

I found that if you ensure that subroutine return values are explicitly set sv_2mortal(), many of the traps "went away", but I fear that I may have been creating SVs that would never get cleaned up?

Hopefully, someone who knows what they are talking about will set the record straight, but maybe this mention will trigger understanding in your brain. I've personally got half a dozen ideas for modules that need XS but on whihc I can make no progress for my failure to understand this mechanism (amongst others:().


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re: [XS] How to detect the TEMP flag by BrowserUk
in thread [XS] How to detect the TEMP flag by syphilis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.