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

stage2: Sema leaks its perm arena #14454

Closed
kubkon opened this issue Jan 25, 2023 · 2 comments
Closed

stage2: Sema leaks its perm arena #14454

kubkon opened this issue Jan 25, 2023 · 2 comments
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@kubkon
Copy link
Member

kubkon commented Jan 25, 2023

Zig Version

0.11.0-dev.1426+d39512755

Steps to Reproduce and Observed Behavior

$ ./stage3/bin/zig build test-cases -Denable-macos-sdk -Denable-llvm -Dforce-gpa

[gpa] (err): memory address 0xcb19ee800 leaked:                                                                                                                           
/Users/kubkon/dev/zig/build/stage3/lib/zig/std/heap/arena_allocator.zig:187:35: 0x1041356b3 in alloc (test)                                                               
            (self.createNode(0, n + ptr_align) orelse return null);                                                                                                       
                                  ^                                                                                                                                       
/Users/kubkon/dev/zig/build/stage3/lib/zig/std/mem/Allocator.zig:86:34: 0x104581d07 in allocAdvancedWithRetAddr__anon_94350 (test)                                        
    return self.vtable.alloc(self.ptr, len, ptr_align, ret_addr);                                                                                                         
                                 ^                                                                                                                                        
/Users/kubkon/dev/zig/build/stage3/lib/zig/std/mem/Allocator.zig:105:52: 0x10438d06f in create__anon_81044 (test)                                                         
    const slice = try self.allocAdvancedWithRetAddr(T, null, 1, @returnAddress());                                                                                        
                                                   ^                                                                                                                      
/Users/kubkon/dev/zig/src/Module.zig:4327:59: 0x10419a2af in semaFile (test)                                                                                              
    const struct_obj = try new_decl_arena_allocator.create(Module.Struct);
                                                          ^
/Users/kubkon/dev/zig/src/Sema.zig:11675:28: 0x1045b79fb in zirImport (test)
    try mod.semaFile(result.file);
                           ^
/Users/kubkon/dev/zig/src/Sema.zig:947:64: 0x1043a3ae7 in analyzeBodyInner (test)
            .import                       => try sema.zirImport(block, inst),
                                                               ^
/Users/kubkon/dev/zig/src/Sema.zig:810:45: 0x1041eb143 in analyzeBodyBreak (test)
    const break_inst = sema.analyzeBodyInner(block, body) catch |err| switch (err) {
                                            ^
/Users/kubkon/dev/zig/src/Module.zig:4519:50: 0x1041e79bb in semaDecl (test)
    const result_ref = (try sema.analyzeBodyBreak(&block_scope, body)).?.operand;

Expected Behavior

No memory leaks are reported.

@kubkon kubkon added bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. labels Jan 25, 2023
@Vexu Vexu added this to the 0.12.0 milestone Jan 25, 2023
@alichraghi
Copy link
Contributor

i just ran zig build test-cases -Denable-llvm -Dforce-gpa. there's no leak in master

@andrewrk
Copy link
Member

Yes this was fixed with the merge of #15569. Thanks @alichraghi

@andrewrk andrewrk modified the milestones: 0.13.0, 0.11.0 Jul 27, 2023
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

No branches or pull requests

4 participants