Conversation
Previously, this input would cause an OOM, but this does not appear to be a valid C++ obfuscation symbol. The LLM believes it has been truncated; the complete symbol is likely this, but it was able to produce correct results previously. |
There was a problem hiding this comment.
Pull request overview
This PR targets the crash/OOM reported in #81 by removing recursive AST node cloning in the Itanium (v3) C++ demangler and introducing a libFuzzer harness to stress those code paths.
Changes:
- Reworked v3 AST ownership to use a
DemContextnode pool andNodeRefreferences instead of deep clones. - Updated v3 parser/pretty-printer plumbing to use the new
NodeRefvectors and safer iteration/bounds checks. - Added an optional Meson fuzz build (
enable_fuzz) and afuzz_demanglelibFuzzer target.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/test_subs.c | Initializes DemContext for substitution table tests and adapts to NodeRef vectors. |
| test/data/cxx_lambda.csv | Adds a new lambda-related demangling test vector. |
| src/microsoft_demangle.c | Adjusts list element free callback signature to match container expectations. |
| src/cplusplus/vec.h | Ensures element destructors run when vectors shrink (resize down). |
| src/cplusplus/v3/v3.c | Large v3 refactor: switches to NodeRef, removes cloning, adds context/node pool init/deinit, adds parser call/recursion limits, and introduces multiple ownership/transfer fixes. |
| src/cplusplus/v3/v3_pp.h | Updates ast_pp prototype to accept NodeRef. |
| src/cplusplus/v3/types.h | Introduces NodeRef, VecNodeRef/VecVecNodeRef, and DemContext node pool; updates many AST fields to NodeRef. |
| src/cplusplus/v3/parser_combinator.c | Updates match_many* to allocate nodes via DemNode_new(p->context) and store children as NodeRef. |
| src/cplusplus/v3/meta.c | Updates parser metadata containers to NodeRef-based vectors and removes output destruction in DemResult_deinit. |
| src/cplusplus/v3/macros.h | Refactors rule macros to allocate via node pool, adds recursion/call limits, and updates AST append helpers for NodeRef. |
| src/cplusplus/v3/ast.c | Updates node construction to register nodes into the DemContext pool; simplifies deinit/copy semantics for the new ownership model. |
| src/cplusplus/demangle.c | Adjusts dispatcher logic for when to try v2/v3-type fallbacks. |
| meson.build | Adds enable_fuzz build flow for a sanitizer/coverage-instrumented fuzz target. |
| meson_options.txt | Adds enable_fuzz option. |
| fuzz/fuzz_demangle.c | New libFuzzer harness targeting v3 demangling entry points. |
| .gitignore | Ignores fuzz/corpus. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
you seems to have some issues with |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Removed all recursive
node clonecalls and added a simple fuzzerfixes #81