refactor: fix TRACEME debug infrastructure for 64-bit#141
Draft
Koan-Bot wants to merge 1 commit into
Draft
Conversation
Three issues in the DEBUG_CLONE tracing code: 1. All pointer prints used %x (unsigned int format) for SV* pointers, which is undefined behavior on 64-bit and truncates addresses to 32 bits. Replaced with PTR2UV() + UVxf (Perl's portable pointer format macros). 2. CLONE_STORE macro's trace output hardcoded 'ref' and 'clone' as variable names — compile error when called from iterative clone functions where the arguments have different names (e.g. inner_sv, new_av). Now uses macro parameters directly. 3. TRACEME macro used __FUNCTION__ (GCC extension) instead of __func__ (C99 standard), and relied on && short-circuit for sequencing printf calls. Replaced with __func__ and do/while(0) wrapper. No changes to production code paths — all modifications are inside #ifdef DEBUG_CLONE blocks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fix three issues in the
DEBUG_CLONEtracing infrastructure that make itunusable on modern 64-bit systems.
Why
The debug tracing code predates the iterative clone functions added
in recent releases. Anyone trying to debug Clone.xs with
-DDEBUG_CLONEwould hit compile errors (from theCLONE_STOREmacro hardcoding variable names) and get truncated pointer addresses
(from
%xformat on 64-bit).How
%x→PTR2UV()+UVxf(Perl's portablepointer format macros, correct on all architectures).
ref/clonevariablenames with the macro's own parameters
x/y.__FUNCTION__→__func__(C99 standard),&&sequencing →do { ... } while (0)wrapper.Testing
DEFINE="-DDEBUG_CLONE"): clean compile, no warnings.#ifdef DEBUG_CLONEblocks.🤖 Generated with Claude Code
Quality Report
Changes: 1 file changed, 19 insertions(+), 16 deletions(-)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline