aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/memdebug_interior.zc
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 16:07:23 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 16:07:23 +0330
commit133865cbdf90a9e5a3b08e260a57f3aa97981f2e (patch)
tree3f7df838785dfc6d0804b95969f07a5fc66ebb3f /tests/programs/memdebug_interior.zc
parentmerge: llvm auto-build (opt-in on x86-64), mode stamp (diff)
memdebug: obj_base finds the header from the buddy size classes, not a 64-word scan; regression program
Diffstat (limited to 'tests/programs/memdebug_interior.zc')
-rw-r--r--tests/programs/memdebug_interior.zc18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/programs/memdebug_interior.zc b/tests/programs/memdebug_interior.zc
new file mode 100644
index 0000000..8464f2c
--- /dev/null
+++ b/tests/programs/memdebug_interior.zc
@@ -0,0 +1,18 @@
+namespace;
+include rt;
+
+// memdebug finds the block of an interior pointer however deep it is: buf[255]
+// of a 256-word block is 255 words past its header, beyond the old 64-word scan.
+memdebug on;
+fn main() {
+ let buf = rt.new(256), small = rt.new(4);
+ buf[255] = 7;
+ buf[100] = 3;
+ small[3] = 2;
+ rt.put_n(buf[255]); rt.put_c(32);
+ rt.put_n(buf[100]); rt.put_c(32);
+ rt.put_n(small[3]); rt.put_c(10);
+ rt.free(small);
+ rt.free(buf);
+ return 0;
+}