Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trailing comma in expression crashes Tree.dump #76

Closed
ehaas opened this issue Nov 5, 2021 · 0 comments
Closed

Trailing comma in expression crashes Tree.dump #76

ehaas opened this issue Nov 5, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@ehaas
Copy link
Collaborator

ehaas commented Nov 5, 2021

Found using fuzz testing

void foo(void) {
    1,;
}

Compile with --verbose-ast:

thread 14001920 panic: reached unreachable code
/Users/ehaas/source/zig/build/lib/zig/std/debug.zig:226:14: 0x10a4dc2f8 in std.debug.assert (arocc)
    if (!ok) unreachable; // assertion failure
             ^
/Users/ehaas/source/arocc/src/Tree.zig:557:21: 0x10a52235b in Tree.dumpNode (arocc)
    std.debug.assert(node != .none);
                    ^
/Users/ehaas/source/arocc/src/Tree.zig:905:30: 0x10a52a0c9 in Tree.dumpNode (arocc)
            try tree.dumpNode(data.bin.rhs, level + delta, w);
                             ^
/Users/ehaas/source/arocc/src/Tree.zig:688:57: 0x10a528297 in Tree.dumpNode (arocc)
            if (data.bin.lhs != .none) try tree.dumpNode(data.bin.lhs, level + delta, w);
                                                        ^
/Users/ehaas/source/arocc/src/Tree.zig:628:30: 0x10a527bf9 in Tree.dumpNode (arocc)
            try tree.dumpNode(data.decl.node, level + delta, w);
                             ^
/Users/ehaas/source/arocc/src/Tree.zig:541:26: 0x10a50ae64 in Tree.dump (arocc)
        try tree.dumpNode(i, 0, writer);
                         ^
/Users/ehaas/source/arocc/src/main.zig:262:18: 0x10a4ecc2d in processSource (arocc)
        tree.dump(buf_writer.writer()) catch {};
                 ^
/Users/ehaas/source/arocc/src/main.zig:223:22: 0x10a4e1161 in handleArgs (arocc)
        processSource(comp, source, builtin, user_macros) catch |e| switch (e) {
                     ^
/Users/ehaas/source/arocc/src/main.zig:41:15: 0x10a4de2ed in main (arocc)
    handleArgs(&comp, args) catch |err| switch (err) {
              ^
/Users/ehaas/source/zig/build/lib/zig/std/start.zig:524:29: 0x10a55bd7c in std.start.callMain (arocc)
            return root.main();
                            ^
/Users/ehaas/source/zig/build/lib/zig/std/start.zig:469:12: 0x10a4e2267 in std.start.callMainWithArgs (arocc)
    return @call(.{ .modifier = .always_inline }, callMain, .{});
           ^
/Users/ehaas/source/zig/build/lib/zig/std/start.zig:434:12: 0x10a4e21a5 in std.start.main (arocc)
    return @call(.{ .modifier = .always_inline }, callMainWithArgs, .{ @intCast(usize, c_argc), c_argv, envp });
@Vexu Vexu added the bug Something isn't working label Nov 5, 2021
@Vexu Vexu closed this as completed in 0856c78 Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants