From XS code, I'd like to obtain the address of either the earliest allocated (lowest memory position) SV*, or some other address below which no memory will be dynamically allocated. Any suggestions of a variable accessible from XS code that fits the bill?

The reason is that some coderefs, for example *DynaLoader::, have links in their opcode chains (as traversed by Devel::Size), that are invalid:

C:\Perl\packages\Devel-Size-X>perl -Mblib -MPOSIX -MDevel::Size=total_ +size -wle" print total_size( *DynaLoader:: )" Devel::Size: Calculated sizes for compiled regexes are incompatible, a +nd probably always will be op_last:019D7014 baseop->op_next: 000000D5 ignored! op_last:0189669C baseop->op_next: 000000D3 ignored! op_last:01892C7C baseop->op_next: 00000084 ignored! 69229

In this case I have observed opcode->op_next with values of 0xD5, OxD3, Ox84. Whilst these are obviously erroneous, there are others like 0x00035ffe somewhere in *POSIX:: that look reasonable, but none the less point to pieces of virual memory that do not exist in the process address space, and so attempting to indirect through them is a walk into oblivion.

So my idea is to find some existing XS-accessible variable who's address is a reasonable lower bound below which D::S will not walk. Whilst this will not prevent all traps through uninitialised pointers, from observations, it would catch a large majority of those that I've seen.

Suggestions?


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 [XS]:The address of the first dynamically allocated SV*? by BrowserUk

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.