Zigler is crashing on X86_64 for []u8 input > 16 bytes

Zigler is crashing the beam for the following code when path is > 16 bytes on Unix X86_64 which works fine on mac, For path < 16 bytes it works fine.

pub fn write_file_and_get_hashes_zig(path: u8, content: u8) beam.term {
// Open file for writing
//const allocator = std.heap.page_allocator;
if (path.len > 4096) {
return beam.make(.{“error”, “Path too long”}, .{});
}

    // Debugging: Print the path and its length
    std.debug.print("Path length: {}\n", .{path.len});
    std.debug.print("Path content: {s}\n", .{path});

    var file = std.fs.createFileAbsolute(path, .{.truncate = true}) catch | err| {
        return beam.make(.{beam.make_error_atom(.{}), "Failed to open file for writing", err}, .{});
    };

    // Ensure the file is closed even if there is an error
    defer file.close();

}

1 Like