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

Payload capture has incorrect debug info #7239

Closed
g-w1 opened this issue Nov 27, 2020 · 2 comments · Fixed by #11222
Closed

Payload capture has incorrect debug info #7239

g-w1 opened this issue Nov 27, 2020 · 2 comments · Fixed by #11222
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@g-w1
Copy link
Contributor

g-w1 commented Nov 27, 2020

Not relevant, look at the comments by Vexu below.

@Vexu
Copy link
Member

Vexu commented Nov 27, 2020

You're putting a pointer to a stack variable into the hashmap:

+    } else {
+        var new_list = try ArrayListUnmanaged(usize).initCapacity(self.gpa, 1);
+        new_list.appendAssumeCapacity(src);
+        try self.compile_log_decls.put(self.gpa, decl, &new_list);
+    }

self.compile_log_decls should have type std.AutoArrayHashMapUnmanaged(*Decl, ArrayListUnmanaged(usize))
self.failed_decls should have type std.AutoArrayHashMapUnmanaged(*Decl, ArrayListUnmanaged(usize)), errors are relatively rare so using little extra memory is acceptable.

@Vexu Vexu closed this as completed Nov 27, 2020
@Vexu Vexu reopened this Nov 27, 2020
@Vexu
Copy link
Member

Vexu commented Nov 27, 2020

Here's a reduction for gdb showing the wrong type:

pub fn main() void {
    var a: ?u16 = 0;
    var b: ?u8 = 1;

    if (a) |*some| {
        @breakpoint(); 
        some.* += 1;
    }

    if (b) |*some| {
        @breakpoint();
        some.* += 1;
    }
}
Program received signal SIGTRAP, Trace/breakpoint trap.
main () at /home/vexu/Documents/zig/zig/build/a.zig:76
76              some.* += 1;
(gdb) ptype some
type = u16 *
(gdb) c
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
main () at /home/vexu/Documents/zig/zig/build/a.zig:81
81              some.* += 1;
(gdb) ptype some
type = u16 *

@Vexu Vexu added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. labels Nov 27, 2020
@Vexu Vexu added this to the 0.8.0 milestone Nov 27, 2020
@Vexu Vexu changed the title gdb showing wrong type Payload capture has incorrect debug info Nov 27, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.10.0 May 19, 2021
@andrewrk andrewrk added frontend Tokenization, parsing, AstGen, Sema, and Liveness. and removed stage1 The process of building from source via WebAssembly and the C backend. labels Mar 19, 2022
@andrewrk andrewrk modified the milestones: 0.11.0, 0.10.0 Mar 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants