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

Memory leak in preprocessor - indirect invocation of macro with incorrect number of arguments #695

Closed
ehaas opened this issue Apr 30, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ehaas
Copy link
Collaborator

ehaas commented Apr 30, 2024

Using the following test case in the test runner causes a memory leak

#define NO_ERROR_VALIDATION
#define h(x) x(0)
#define s()
h(s)
error(gpa): memory address 0x10c89f500 leaked:
/Users/ehaas/local/zig-macos-x86_64-0.13.0-dev.44+9d64332a5/lib/std/array_list.zig:457:67: 0x1061a8903 in ensureTotalCapacityPrecise (test-runner)
                const new_memory = try self.allocator.alignedAlloc(T, alignment, new_capacity);
                                                                  ^
/Users/ehaas/local/zig-macos-x86_64-0.13.0-dev.44+9d64332a5/lib/std/array_list.zig:434:51: 0x106124c0e in ensureTotalCapacity (test-runner)
            return self.ensureTotalCapacityPrecise(better_capacity);
                                                  ^
/Users/ehaas/source/arocc/src/aro/Tree.zig:67:37: 0x106124451 in addExpansionLocation (test-runner)
        try list.ensureTotalCapacity(wanted_len);
                                    ^
/Users/ehaas/source/arocc/src/aro/Tree.zig:86:38: 0x1061fbc50 in dupe (test-runner)
        try copy.addExpansionLocation(gpa, tok.expansionSlice());
                                     ^
/Users/ehaas/source/arocc/src/aro/Preprocessor.zig:2110:43: 0x1061fd155 in collectMacroFuncArguments (test-runner)
                const duped = try tok.dupe(pp.gpa);
                                          ^
/Users/ehaas/source/arocc/src/aro/Preprocessor.zig:2211:62: 0x10619a204 in expandMacroExhaustive (test-runner)
                    const args = pp.collectMacroFuncArguments(
                                                             ^

@ehaas ehaas added the bug Something isn't working label Apr 30, 2024
@ehaas ehaas changed the title Memory leak in preprocessor - indirectly invocation of macro with incorrect number of arguments Memory leak in preprocessor - indirect invocation of macro with incorrect number of arguments Apr 30, 2024
@Vexu Vexu closed this as completed in 9c1bddf May 3, 2024
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

1 participant