← Back to Pull requests

Fix dtrace invalid address messages, at least on OS X #24914

Open
tonycoz opened this pull request with 43 lines diff across 3 files
View on GitHub
tonycoz tonycoz commented on Oct 07, 2026 03:07 UTC
Author

<!--
A good description should explain the problem the pull request addresses
and give context to the reviewers to aid them in their reviews.
If this addresses an open issue, please reference it in this format: GH #12345
so that GitHub adds a link in that issue to this new pull request.
-->
This builds on some previous commits, adding:
- a way to have run/dtrace.t use sudo to run dtrace
- use that in CI
- make sure the strings we pass to dtrace are available to be copied, fixing "invalid address" messages from dtrace

I'm a little hesitant about writing to a global volatile, conceivably tsan will complain about it.

I use strlen() since that will touch every char in the string p to the NUL, which is what dtrace needs.

Based on a lot of work already done by @sevan in #24860

-------------------------------------------------------------------------------
<!--
Significant or noteworthy changes to Perl must be documented in pod/perldelta.pod.

Consider if the changes in this pull request are worthy of a perldelta
entry, then pick the appropriate line below and remove the others.
-->

  • This set of changes requires a perldelta entry, and it hasn't been written yet.
  • Diff: 43 lines (+37 / -6) across 3 files Reviewer: bulk88 Review duration: 26231m
    All Vouch review confidence checks passed
    Residual risk 0.03 = Change Risk (0.29) × (1 − Review Confidence (0.89)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.29 · 43 lines diff across 3 files
    0.29
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.95 · 5 substantive comment(s)
    0.95
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    89%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.226
    Real PR Conversation Timeline
    15 items
    sevan sevan commented on Oct 08, 2026 00:40 UTC
    Contributor

    PowerPC system is uniprocessor
    x86 systems are dual core2duo & quad core xeon & i5
    arm64 system is an M1

    10.5 without patch on PowerPC only usedtrace - all pass
    10.5 without patch on PowerPC usedtrace + useshrplib - test 3,4,6,7 breakage
    10.5 without patch on PowerPC usedtrace + usethreads - all pass
    10.5 without patch on PowerPC usedtrace + useshrplib + usethreads - test 3,4,6,7 breakage
    10.5 with patch on PowerPC useshrplib - all pass, no invalid address messages
    10.5 with patch on PowerPC usedtrace + useshrplib + usethreads - all pass, no invalid address messages
    10.5 without patch on x86 only usedtrace - test 8 & 9 fail
    10.5 without patch on x86 with usedtrace + usethreads + useshrplib - test 8 & 9 fail, intermittently
    10.5 with patch on x86 with usedtrace + usethreads + useshrplib - test 8 & 9 fail, intermittently, no invalid address messages
    10.6 without patch on x86 only usedtrace - test 8 & 9 fail, intermittently
    10.6 with patch on x86 only usedtrace - test 8 & 9 fail, intermittently, no invalid address messages
    10.7 without patch on x86 only usedtrace - test 8 & 9 fail, intermittently
    10.7 with patch on x86 only usedtrace - test 8 & 9 fail, intermittently
    10.9 without patch on x86 only usedtrace - test 8 & 9 fail, intermittently
    10.9 without patch on x86 only usedtrace + usethreads - test 8 & 9 fail, intermittently
    10.9 without patch on x86 only usedtrace + useshrplib - test 3,4,6,7 breakage, test 8 & 9 fail, intermittently
    10.9 without patch on x86 only usedtrace + useshrplib + usethreads - test 3,4,6,7 breakage, test 8 & 9 fail, intermittently
    10.9 with patch on x86 only usedtrace + useshrplib + usethreads - test 8 & 9 fail, intermittently, no invalid address messages
    10.10 without patch on x86 only usedtrace - all pass
    10.10 without patch on x86 only usedtrace + usethreads - all pass
    10.10 without patch on x86 only usedtrace + useshrplib - test 3,4,6,7 breakage
    10.10 without patch on x86 only usedtrace + useshrplib + usethreads - test 3,4,6,7 breakage
    10.10 with patch on x86 only usedtrace + useshrplib + usethreads - all pass, no invalid address messages
    10.11 without patch on x86 only usedtrace - all pass
    11 without patch on arm64 only usedtrace -all pass
    11 without patch on arm64 with usedtrace + usethreads - all pass
    11 without patch on arm64 with usedtrace + usethreads + useshrplib - test 3,4,6,7 breakage
    11 with patch on arm64 with usedtrace + usethreads + useshrplib - all pass
    12 without patch on x86 only usedtrace -all pass
    12 without patch on x86 with usedtrace + usethreads - all pass
    12 without patch on x86 with usedtrace + usethreads + useshrplib - test 3,4,6,7 breakage
    12 with patch on x86 with usedtrace + usethreads + useshrplib - all pass

    bulk88 bulk88 commented on code on Oct 11, 2026 05:53 UTC
    Code Review
    util.c:1
    @@ -6863,6 +6863,22 @@ int perl_tsa_mutex_destroy(perl_mutex* mutex)
     
     #ifdef USE_DTRACE
     
    +volatile STRLEN force_page_in_temp;
    +
    +PERL_STATIC_INLINE void
    +force_page_in(const char *s) {
    +  /* touch every element of the string so dtrace copyinstr() can
    +     see it, from the dtrace manual:
    +
    +     The copyin() and copyinstr() subroutines cannot read from user
    +     addresses which have not yet been touched. A valid address might
    +     cause an error if the page that contains that address has not
    +     been faulted in by an access attempt.
    +  */
    +  if (s)
    +    force_page_in_temp = strlen(s);

    Any time I see strlen() there is always a better solution than it.

    Since you are talking about "pages", the red line in the C Abstract Machine has been crossed, and there is no more pretending that all systems immediately SEGV when char ch = SvPVX(sv)[SvLEN(sv)]; or char ch = SvPVX(sv)[-1]; execute.

    The problem stated in the comment can be solved by read only 1 byte per each 4096 byte page. The address of page containing a specific pointer is found by doing a natural alignment equation on that specific pointer. There are different ways to do that rounding equation in C but they all produce the same number.

    Next question, what is the scope of the portability question? >= 95% of all CPUs on earth use 4KB pages. Some exceptions which are all retro computing by now, I know of are SH4 CPUs have 1024 bytes supposedly. Itanium maybe has 8192.

    https://en.wikipedia.org/wiki/Page_(computer_memory)
    https://devblogs.microsoft.com/oldnewthing/20210510-00/?p=105200/

    The Perl API has a variable with this info called PL_mmap_page_size

    https://github.com/Perl/perl5/blob/blead/perlvars.h#L110

    I have no experience with it since Win32 Perls don't have it, and I don't know if it accurate on a Unix Perl or part of an ancient feature that is now-broken and needs repairs in 2026.

    Its also has a defect in its declaration quoted here

    PERLVARI(G, mmap_page_size, IV, 0)
    

    Type IV? A 64 bit container? 16 Exabytes? Whoever has a rack server with 8 GB pages and 512 Petabytes of DDR4 running Perl needs to speak up and send me a cargo truck or two of their blessing.

    An easy example of touching 1 or 8 bytes every 4096 bytes of address space is Win32's and Win64's platform required code for oversized fixed width C auto arrays and _alloca()'s assembly language level implementation.

    Here are some example of the algo in asm

    https://github.com/ahmedarif193/LiberNT/blob/55f72aaa63924f9b8e58302b4a388b55cb28fe84/sdk/lib/crt/except/amd64/chkstk_ms.s#L25

    https://skanthak.hier-im-netz.de/msvcrt.html#chkstk

    but I gave up searching for a readable C equivelent even though I know they have to be out there since disabling GCC/Clang/Visual C's alloca() and replacing it with your own alloca() is a long time supported feature of Windows https://learn.microsoft.com/en-us/cpp/build/reference/gs-control-stack-checking-calls?view=msvc-170 .

    The phrase "disabling GCC/Clang/Visual C's alloca() and replacing it with your own alloca()" in plain english means the developer certifies that they know how to identify a C auto var and that they how to write a for() or while() loop that starts copying from the highest address towards the lowest address going backwards.

    Since your input is a null terminated string according to the prototype PERL_STATIC_INLINE void force_page_in(const char s), you can not skip any bytes between each 4096 page or you will never know where the C string officially ends.

    Therefore there is no choice except to use strlen() if prototype of PERL_STATIC_INLINE void force_page_in(const char s) will stay as it is.

    bulk88 bulk88 commented on code on Oct 11, 2026 07:43 UTC
    Code Review
    util.c:1
    @@ -6863,6 +6863,22 @@ int perl_tsa_mutex_destroy(perl_mutex* mutex)
     
     #ifdef USE_DTRACE
     
    +volatile STRLEN force_page_in_temp;

    This is an poor and unreliable way to disable CSE/dead code/tree shaking/const folding in C.

    All C compilers on Windows that have their LTO feature turned on will optimize this away. Maybe even LTO being off will optimize this away, because 1 of the flags that are anything but -Od/-O0 was able to optimize it away.

    The Win32/64 platform and its PE format have a Day 1 ABI rule that writing extern in C source code that compiles to PE is equivalent to writing inline __attribute__((noinline)) in C source code for Linux.

    Note lack of a 6 letter word starting with the letter s.

    To guarantee volatile STRLEN force_page_in_temp; can't optimize away on windows, using the anti-const folding design choice you used, I would have to put a __declspec(dllexport) or it's GCC twin on the left side of STRLEN and possibly then go mess with a .def file or add it to

    WriteMakefile( ..., FUNCLIST => [ 'force_page_in_temp DATA' ], ...)

    which cause this to appear in the Makefile

    # --- MakeMaker dlsyms section:
    
    MyXSMod.def: Makefile.PL
    	$(PERLRUN) -MExtUtils::Mksymlists \
         -e "Mksymlists('NAME'=>\"Local::MyXSMod\", 'DLBASE' => '$(BASEEXT)', 'DL_FUNCS' => {  }, 'FUNCLIST' => [q[boot_Local__MyXSMod], q[force_page_in_temp DATA]], 'IMPORTS' => {  }, 'DL_VARS' => []);"
    

    What I did above isn't a perfect example since force_page_in_temp isn't a function symbol. It is a data symbol. And because of Win32 special-ness that takes too long to talk about, all Win32 and maybe Z/OS (uses .defs & .dlls IIRC) C linkers really really wants to know if that ASCII string's (symbol's) relative offset into a .o file has machine code or not machine code at its destination.

    I don't remember why I am not use EU::MM's DL_VARS option It probably has bugs in it and doesn't know how to use the DATA token. https://metacpan.org/pod/ExtUtils::Mksymlists#FUNCLIST docs guarentee no helpful "preprocessing" is done on the user's symbol names.

    On OSX and Linux, this global not static data var needs to be findable with dl_open()/dl_sym() or it is at risk of optimizing away.

    IDK how Unix/ELF/SysV "symbol visibility" works but Perl 5 has had strict symbol hiding for the last 7 years on Linux.

    The string force_page_in_temp is also a violation of Perl CORE's naming style rules. All Host OS true C global vars visible between 2 TU's of LibPerl need to have the PL_ prefix. Since force_page_in_temp needs to be visible outside of LibPerl the disk file, i.e. visible to XS module that will never exist since they have no reason to ever link to the PL_force_page_in_temp symbol even tho its in LibPerl's export or symbol table, that now means force_page_in_temp needs to be part of Perl's official symbol management system.

    That means its listed in https://github.com/Perl/perl5/blob/blead/perlvars.h which is not to be confused with the my_perl/pTHX vars that live inside the https://github.com/Perl/perl5/blob/blead/intrpvar.h file. I don't remember the full process, but probably it involves a regen.pl and other parts of it live at https://github.com/Perl/perl5/blob/blead/globvar.sym https://github.com/Perl/perl5/blob/blead/perlio.sym and RO global data symbols are mostly hang out at https://github.com/Perl/perl5/blob/blead/perl.h#L5794

    1/8 to a 1/4 of RO global data symbols are randomly spread out the .inc, .lst, .h, and .c in https://github.com/Perl/perl5/blob/blead/ 's root directory.

    Irrelavent to this PR, but the grandfathered legacy or strange special cases live inside https://github.com/Perl/perl5/blob/blead/makedef.pl and I belive special code inside https://github.com/Perl/perl5/blob/blead/makedef.pl is the only way to make a non-PL_* global var in Perl CORE if there was ever a need to have to make in the future.

    Remember technical measures put in place in libperl.so/bin/perl to stop accidents like volatile STRLEN force_page_in_temp; from happening when static volatile STRLEN force_page_in_temp; is missing its static keyword.

    PL_force_page_in_temp's proper place is most likely https://github.com/Perl/perl5/blob/blead/perlvars.h

    IMO creating a whole new single purpose rarely used global data var is bloat.

    The XS API already has a designated volatile trashcan for doing PL_force_page_in_temp's purpose and it's C type has the same spelling as PL_force_page_in_temp's C type.

    It is called PL_na https://github.com/Perl/perl5/blob/blead/intrpvar.h#L277

    PL_na is a my_perl var. You will need to add pTHX_ to the prototype.

    bulk88 bulk88 commented on code on Oct 11, 2026 07:46 UTC
    Code Review
    util.c:1
    @@ -6889,6 +6905,11 @@ Perl_dtrace_probe_call(pTHX_ CV *cv, bool is_call)
         line  = CopLINE(start);
         stash = CopSTASHPV(start);
     
    +    /* ensure they are paged in */
    +    force_page_in(func);

    func = HEK_KEY(hek);'s byte length is available using HEK_LEN(). Using strlen() here is wrong.

    For the GV* object, pick your posion,

    #define GvNAME_HEK(gv)	(GvXPVGV(gv)->xiv_u.xivu_namehek)
    #define GvNAME_get(gv)	HEK_KEY(GvNAME_HEK(gv))
    #define GvNAMELEN_get(gv)	HEK_LEN(GvNAME_HEK(gv))
    #define GvNAMEUTF8(gv)	HEK_UTF8(GvNAME_HEK(gv))
    #define GvENAME(gv)	GvNAME(GvEGV(gv) ? GvEGV(gv) : gv)
    #define GvENAMELEN(gv)  GvNAMELEN(GvEGV(gv) ? GvEGV(gv) : gv)
    #define GvENAMEUTF8(gv) GvNAMEUTF8(GvEGV(gv) ? GvEGV(gv) : gv)
    #define GvENAME_HEK(gv) GvNAME_HEK(GvEGV(gv) ? GvEGV(gv) : gv)
    

    many token flavors to choose from.

    bulk88 bulk88 commented on code on Oct 11, 2026 07:59 UTC
    Code Review
    util.c:1
    @@ -6889,6 +6905,11 @@ Perl_dtrace_probe_call(pTHX_ CV *cv, bool is_call)
         line  = CopLINE(start);
         stash = CopSTASHPV(start);
     
    +    /* ensure they are paged in */
    +    force_page_in(func);
    +    force_page_in(file);

    Perl 5's CopFILE() has multiple internal implementations depending on both interp build config options AND year/version/age of the perl.

    As of now all CopFILE()s are binary safe and are length tracked. strlen() code doesn't belong here.

    The impls currently are

    #  define CopFILE_LEN(c)        (CopFILE(c) ? RCPV_LEN(CopFILE(c)) : 0)
    

    or
    #  define CopFILE_LEN(c)	(CopFILEGV(c) /* -2 for '_<' */ ? GvNAMELEN(CopFILEGV(c))-2 : 0)
    

    Macro # define CopFILE_LEN(c) is somewhat new. Its only a couple years old. It wasn't around 10 or 15 yeras ago. The macro can be polyfilled with strlen() for ancient Perls.

    bulk88 bulk88 commented on code on Oct 11, 2026 08:07 UTC
    Code Review
    util.c:1
    @@ -6889,6 +6905,11 @@ Perl_dtrace_probe_call(pTHX_ CV *cv, bool is_call)
         line  = CopLINE(start);
         stash = CopSTASHPV(start);
     
    +    /* ensure they are paged in */
    +    force_page_in(func);
    +    force_page_in(file);
    +    force_page_in(stash);

    again, stash = CopSTASHPV(start); is length tracked

    #define CopSTASHPV(c)		(CopSTASH(c) ? HvNAME_get(CopSTASH(c)) : NULL)
    

    struct COP has 2 implementations
    #  define CopSTASH(c)		((c)->cop_stash)
    

    or
    #  define CopSTASH(c)           PL_stashpad[(c)->cop_stashoff]
    

    The retval type of CopSTASH() is HV.

    #define HvNAME_get(hv)         (HvHasNAME(hv) ? HEK_KEY(HvNAME_HEK_NN(hv)) : NULL)
    

    GREP your perl5/lib/CORE/.
    h folder before writing any PerlCEE code.

    bulk88 bulk88 commented on code on Oct 11, 2026 10:15 UTC
    Code Review
    util.c:1
    @@ -6920,8 +6942,9 @@ void
     Perl_dtrace_probe_op(pTHX_ const OP *op)
     {
         PERL_ARGS_ASSERT_DTRACE_PROBE_OP;
    -
    -    PERL_OP_ENTRY(OP_NAME(op));
    +    const char *op_name = OP_NAME(op);

    #define OP_NAME(o) ((o)->op_type == OP_CUSTOM \
                        ? XopENTRYCUSTOM(o, xop_name) \
                        : PL_op_name[(o)->op_type])
    

    Ignore the OP_CUSTOM ? XopENTRYCUSTOM(o, xop_name) part. It is unrealistic. Custom OPs are supported by Perl but are never used on CPAN or by any public code except for CPAN modules whose description line says "GET YOUR CUSTOM OPS RIGHT NOW! FREE DOWNLOAD!" jkjk

    XopENTRYCUSTOM(o, xop_name) is a function call that will eventually trigger a hv_fetch() lookup.

    PL_op_name[(o)->op_type] is an array in LibPerl's .rodata section containing pointers to C strings in LibPerl's .rodata section.

    START_EXTERN_C
    
    EXTCONST char* const PL_op_name[] INIT({
    	"null",
    	"stub",
    	"scalar",
    	"pushmark",
    	"wantarray",
    	"const",
    

    Sadly the byte lengths of these C strings is not available :-(

    strlen() will have to be used. Or Not? :-)

    After doing the fundamental ground rule of C which is that types and algorithms shall be sized to the minimums and maximums of the data they will contain, which took me 4 seconds,

    "aelemfastlex_store" at 18 bytes is the longest string. 19 bytes after including '\0'.

    There is an API guarentee that P5P will never name a Perl 5 OP_ or Perl_pp_() with a name longer than 4095 characters.

    I am not going to prove it here with code, but there is a good chance real world limit for every char in this Pull Request is the byte length of this array.
    ''
    char tokenbuf[ PERL_IDENTIFIER_LENGTH ];

    which is
    

    #define PERL_IDENTIFIER_LENGTH (256
    MAX_UNICODE_UTF8_BYTES)
    
    Since the upper bounds of the strings in the `OP_NAME()`
    

    Perl_dtrace_probe_op(pTHX_ const OP op)
    {
    PERL_ARGS_ASSERT_DTRACE_PROBE_OP;
    const char
    op_name = OP_NAME(op);
    force_page_in(op_name);
    PERL_OP_ENTRY(op_name);
    `
    have a known limit and are stored in
    .rodata, using LibC's strlen() function is inappropriate. A 1 byte U8 deref to &(PL_op_name[(o)->op_type][0]) is enough to cause a page fault on top of page that covers the 18 or fewer bytes making up the string.

    2 unaligned U64 reads or 1 unaligned16 byte SIMD read will pedantically touch (read) all bytes in all of the name strings except the last 2 bytes of the 18 one.

    My local 5.45.4 X64's .rdata is 0x180351000-0x180166000=0x1EB000=2,011,136 bytes long

    00x1EB000/4096 == 491 pages, most of which goes for the uniprops tables.

    Perl's .rodata` will probably quickly page in and touching each and every one of these strings and this data wont be very useful is my thoughts.

    I have no knowledge of what "DTrace" is except it start with the letter "D", a common abbreviation for Debug, and it end with the word "Trace" and I think Tracing Tools are wonderful! What do you want to know about them? Are you trying to write your own src code unavailable C profiler? :-)

    sevan sevan commented on code on Oct 12, 2026 01:28 UTC
    Code Review
    util.c:1
    @@ -6863,6 +6863,22 @@ int perl_tsa_mutex_destroy(perl_mutex* mutex)
     
     #ifdef USE_DTRACE
     
    +volatile STRLEN force_page_in_temp;
    +
    +PERL_STATIC_INLINE void
    +force_page_in(const char *s) {
    +  /* touch every element of the string so dtrace copyinstr() can
    +     see it, from the dtrace manual:
    +
    +     The copyin() and copyinstr() subroutines cannot read from user
    +     addresses which have not yet been touched. A valid address might
    +     cause an error if the page that contains that address has not
    +     been faulted in by an access attempt.
    +  */
    +  if (s)
    +    force_page_in_temp = strlen(s);

    Next question, what is the scope of the portability question? >= 95% of all CPUs on earth use 4KB pages. Some exceptions which are all retro computing by now, I know of are SH4 CPUs have 1024 bytes supposedly. Itanium maybe has 8192.

    For Darwin, it's 4KB for PowerPC and x86. 16KB on arm64.

    sevan sevan commented on code on Oct 12, 2026 01:36 UTC
    Code Review
    util.c:1
    @@ -6920,8 +6942,9 @@ void
     Perl_dtrace_probe_op(pTHX_ const OP *op)
     {
         PERL_ARGS_ASSERT_DTRACE_PROBE_OP;
    -
    -    PERL_OP_ENTRY(OP_NAME(op));
    +    const char *op_name = OP_NAME(op);

    I have no knowledge of what "DTrace" is except it start with the letter "D", a common abbreviation for Debug, and it end with the word "Trace" and I think Tracing Tools are wonderful! What do you want to know about them? Are you trying to write your own src code unavailable C profiler? :-)

    Close, D is for Dynamic.
    We're trying to get the support in Perl currently going again. The tests and this pull requests bends things so things are ready for instrumentation.
    Remember I was asking about Windows Server the other day? that's now got this tool built in. You can also install it on Windows 10 / 11.
    If you have a Ubuntu 24 or newer install, it comes with a tool called bpftrace when you can use with the dtrace support in Perl. See https://github.com/Perl/perl5/issues/24860#issuecomment-5797939576 and the perldtrace pod in blead. Syntax is stlightly different in bpftrace to DTrace, but the document will show what sort of things are currently in perl.

    tonycoz tonycoz commented on code on Oct 18, 2026 23:40 UTC
    Code Review
    util.c:1
    @@ -6889,6 +6905,11 @@ Perl_dtrace_probe_call(pTHX_ CV *cv, bool is_call)
         line  = CopLINE(start);
         stash = CopSTASHPV(start);
     
    +    /* ensure they are paged in */
    +    force_page_in(func);

    This is irrelevant - the aim is to touch the entire string to ensure it is paged in, fetching the length elsewhere is useless.

    Now typically in this case the string will be paged in, but if the function name hasn't been accessed recently and there is significant memory pressure (we're swapping madly), the name may have been paged out.

    tonycoz tonycoz commented on code on Oct 18, 2026 23:41 UTC
    Code Review
    util.c:1
    @@ -6889,6 +6905,11 @@ Perl_dtrace_probe_call(pTHX_ CV *cv, bool is_call)
         line  = CopLINE(start);
         stash = CopSTASHPV(start);
     
    +    /* ensure they are paged in */
    +    force_page_in(func);
    +    force_page_in(file);

    Misses the point.

    sevan sevan commented on Oct 22, 2026 21:24 UTC
    Contributor

    Thet/run/dtrace.t change should land as it's beneficial for smokers, regardless of issues on Darwin, and enabling it on the github runners.

    bulk88 bulk88 commented on code on Oct 23, 2026 00:23 UTC
    Code Review
    util.c:1
    @@ -6863,6 +6863,22 @@ int perl_tsa_mutex_destroy(perl_mutex* mutex)
     
     #ifdef USE_DTRACE
     
    +volatile STRLEN force_page_in_temp;
    +
    +PERL_STATIC_INLINE void
    +force_page_in(const char *s) {
    +  /* touch every element of the string so dtrace copyinstr() can
    +     see it, from the dtrace manual:
    +
    +     The copyin() and copyinstr() subroutines cannot read from user
    +     addresses which have not yet been touched. A valid address might
    +     cause an error if the page that contains that address has not
    +     been faulted in by an access attempt.
    +  */
    +  if (s)
    +    force_page_in_temp = strlen(s);

    For Darwin, it's 4KB for PowerPC and x86. 16KB on arm64.

    Google says Arm64 is 4KB. Apple's official API docs are very "corporate"/undefined behavior weasel wording on the topic. Apple says something like "Apple Arm64 CPUs use 4KB physical pages and 16KB virtual memory pages."

    What does that mean? That the ARM64 CPU is using 4KB pages on a bare metal/booting an "unauthorized" Debian Kernel assembly lang level, but all builds of Apple iOS/OSX OSes for ARM64 ISA come with Mach Kernels that have been configured to combine every 4 HW pages of 4KB length into 1 high level "public API" page of 16KB length?

    I'm guessing that means all 16 KB units of address space aligned to 16KBs is the smallest granularity unit of VM the Apple Mach kernels record any metadata/perms/state for, as a performance enhancement. All 4 X 4KB ARM64 pages are in phy RAM at the same time, or none of them are in phy RAM. Page fault handler will always bring in the other 3 4KB pages if a read/write fault (SIGBUS) fires on any 1 of the 4 pages?

    Win32's/NT Kernel's design rule of 65KB is the minimum unit of Vir Addr Space that can be allocated with a severely restricted feature set of what properties/perms/metadata can be set at the unit of 4KB of addr space granularity inside each 64KB unit of addr space.

    Linux Kernel has no such architectural optimizations/architectural restrictions and records metadata/perms/state in units of 4KB with the adjacent lower and higher 4KB pages being totally independent and their state has no relavention to the state of the 4KB page in question. This is what I learned from my research on the topic.

    The only noteworthy thing about Linux Kernel's design is, void * ptr = malloc(32); if (ptr== NULL) {strcpy(ptr, "unit test passed"); printf(ptr);} is an actual unit test of the Linux Kernel and required behavior. Obviously multiple obscure rarely used runtime Kernel options were manually changed to allow NULL pointer and all address < 4096 to be normal read/write memory. Video game/arcade game emulators for Linux use this in production for CPU emulation. Linux's next organizational unit above 4KB is 16MB. Glibc's malloc ASLR doesn't change any portion of the address below an aligned 16MB unit. The address bits below 16MB are identical between each LinPerl process when I tested it.

    bulk88 bulk88 commented on code on Oct 23, 2026 18:23 UTC
    Code Review
    util.c:1
    @@ -6920,8 +6942,9 @@ void
     Perl_dtrace_probe_op(pTHX_ const OP *op)
     {
         PERL_ARGS_ASSERT_DTRACE_PROBE_OP;
    -
    -    PERL_OP_ENTRY(OP_NAME(op));
    +    const char *op_name = OP_NAME(op);

    > I have no knowledge of what "DTrace" is except it start with the letter "D", a common abbreviation for Debug, and it end with the word "Trace" and I think Tracing Tools are wonderful! What do you want to know about them? Are you trying to write your own src code unavailable C profiler? :-)

    > Close, D is for Dynamic. We're trying to get the support in Perl currently going again. The tests and this pull requests bends things so things are ready for instrumentation. Remember I was asking about Windows Server the other day? that's now got this tool built in. You can also install it on Windows 10 / 11. If you have a Ubuntu 24 or newer install, it comes with a tool called bpftrace when you can use with the dtrace support in Perl.

    I read perldtrace.pod, from my understanding it's almost identical to a commercial Visual C based profiler I used to use. Dtrace requires C source code access and recompiling the application or portions of it's .so/.dll files that someone is interested in, otherwise dtrace and my commercial profiler fallback to a nearly useless crippled mode where they intercept at the PLT/GOT/Win32 Import symbol table level.

    The POD docs sentences that say "the callers PP sub name is not available" is a trivial feature to implement. All the code for walking the PP callstack lives in pp_caller(), send it through the CPP and read the .i file. Ive previously written a C plain old data expression to obtain the current, -1 or -2 PP sub name for Visual Studio's Variable Watch/ISO C repl prompt. It's 3 80 or 480 characters long but contains no function calls.

    Reviewers
    Assignees
    tonycoz tonycoz
    Labels
    risk: low confidence: 89.4% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 28.6% (LOW) · Higher = larger blast radius
    28.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 89.4% · Lower = rushed or shallow review
    89.4%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 3% · Safe to merge
    3%
    Repository