Use the actual constant

This commit is contained in:
Richard Feldman 2025-12-07 19:18:07 -05:00
parent e8541d319f
commit 341f0f03c4
No known key found for this signature in database
2 changed files with 14 additions and 11 deletions

View file

@ -1584,14 +1584,16 @@ test "fx platform sublist method on inferred type" {
}
test "fx platform repeating pattern segfault" {
// File: test/fx/repeating_pattern_segfault.roc
// SKIP: This test exposes a compiler bug where variables used multiple times
// in consuming positions don't get proper refcount handling. Specifically,
// Regression test: This test exposed a compiler bug where variables used multiple times
// in consuming positions didn't get proper refcount handling. Specifically,
// in `repeat_helper(acc.concat(list), list, n-1)`, the variable `list` is
// passed to both concat (consuming) and to the recursive call (consuming),
// but the compiler doesn't insert a copy/incref for the second use.
// This causes a use-after-free when concat consumes the list.
// TODO: Re-enable this test once the compiler properly handles multiple
// consuming uses of the same variable.
return error.SkipZigTest;
// passed to both concat (consuming) and to the recursive call (consuming).
// The compiler must insert a copy/incref for the second use to avoid use-after-free.
const allocator = testing.allocator;
const run_result = try runRoc(allocator, "test/fx/repeating_pattern_segfault.roc", .{});
defer allocator.free(run_result.stdout);
defer allocator.free(run_result.stderr);
try checkSuccess(run_result);
}

View file

@ -8,6 +8,7 @@ const builtins = @import("builtins");
const base = @import("base");
const can = @import("can");
const types = @import("types");
const collections = @import("collections");
const import_mapping_mod = types.import_mapping;
const eval = @import("eval");
const ipc = @import("ipc");
@ -208,9 +209,9 @@ fn setupModuleEnv(shm: *SharedMemoryAllocator, roc_ops: *RocOps) ShimError!Setup
// Use signed arithmetic to avoid overflow on 64-bit addresses
const offset: i64 = @as(i64, @intCast(child_base_addr)) - @as(i64, @intCast(parent_base_addr));
// Verify offset preserves 16-byte alignment (ASLR can cause misaligned shared memory mapping)
// Verify offset preserves alignment (ASLR can cause misaligned shared memory mapping)
if (comptime builtin.mode == .Debug) {
const REQUIRED_ALIGNMENT: u64 = 16; // SERIALIZATION_ALIGNMENT
const REQUIRED_ALIGNMENT: u64 = collections.SERIALIZATION_ALIGNMENT.toByteUnits();
const abs_offset: u64 = @abs(offset);
if (abs_offset % REQUIRED_ALIGNMENT != 0) {
const err_msg = std.fmt.bufPrint(&buf, "Relocation offset 0x{x} not {}-byte aligned! parent=0x{x} child=0x{x}", .{