Stream: bugs

Topic: crashes with alignment panic during builtin loading


view this post on Zulip nandi (Jan 19 2026 at 20:10):

Bug Report: rocn crashes with alignment panic during builtin loading

Summary

rocn crashes with an alignment panic during builtin module deserialization. The crash occurs before any user code is processed, making it impossible to use rocn with local platforms.

Version Info

Roc compiler version debug-bcb502a3

Environment

Minimal Reproduction

mkdir -p /tmp/rocn-bug/platform && cd /tmp/rocn-bug

# Create minimal platform
cat > platform/main.roc << 'EOF'
platform ""
    requires {} { main! : {} => {} }
    exposes []
    packages {}
    provides { main_for_host!: "main_for_host" }
    targets: {
        files: "targets/",
        exe: {
            x64musl: ["libhost.a", app],
        }
    }

main_for_host! : {} => I32
main_for_host! = |{}|
    main!({})
    0
EOF

# Create minimal app
cat > main.roc << 'EOF'
app [main!] { pf: platform "./platform/main.roc" }

main! = |{}| {}
EOF

# Trigger crash
rocn main.roc

Stack Trace

thread panic: incorrect alignment
/home/nandi/code/roc/src/collections/safe_list.zig:178:45: in deserialize
    const items_ptr: [*]T = @ptrFromInt(base +% @as(usize, @intCast(self.offset)));
                            ^
/home/nandi/code/roc/src/canonicalize/NodeStore.zig:4058:74: in deserialize
    const deserialized_int128_values = self.int128_values.deserialize(base_addr).*;
                                                                     ^
/home/nandi/code/roc/src/canonicalize/ModuleEnv.zig:2262:44: in deserialize
    .store = self.store.deserialize(base_addr, gpa).*,
                                   ^
/home/nandi/code/roc/src/eval/builtin_loading.zig:50:47: in loadCompiledModule
    const env = try serialized_ptr.deserialize(base_addr, gpa, source, module_name);
                                              ^
/home/nandi/code/roc/src/eval/BuiltinModules.zig:57:68: in init
    var builtin_module = try builtin_loading.loadCompiledModule(allocator,
        compiled_builtins.builtin_bin, "Builtin", compiled_builtins.builtin_source);
                                                                   ^
/home/nandi/code/roc/src/cli/main.zig:1684:55: in setupSharedMemoryWithModuleEnv
    var builtin_modules = try eval.BuiltinModules.init(ctx.gpa);
                                                      ^
/home/nandi/code/roc/src/cli/main.zig:1244:58: in rocRun
    const shm_result = try setupSharedMemoryWithModuleEnv(ctx, args.path, args.allow_errors);
                                                         ^

Analysis

The crash occurs in BuiltinModules.init() during deserialization of pre-compiled builtin modules. Specifically, int128_values in the NodeStore has incorrect alignment when being deserialized from the embedded binary.

This suggests either:

  1. The compiled_builtins.builtin_bin was compiled with different alignment requirements than the current runtime
  2. There's a serialization/deserialization mismatch for 128-bit integer types
  3. The embedded binary is corrupted or incompatible with the current Zig version

Workaround

None known. The crash occurs before user code is processed, so it affects all uses of rocn with local platforms.

view this post on Zulip Richard Feldman (Jan 20 2026 at 01:48):

what is rocn? :sweat_smile:

view this post on Zulip nandi (Jan 20 2026 at 01:49):

its my symlink to new compiler heh i think i was thinking "roc new" or something

view this post on Zulip nandi (Jan 20 2026 at 01:50):

I built again and i think error went away so not sure if this was because stale code or not


Last updated: Feb 20 2026 at 12:27 UTC