Skip to content

Fix segfault in declaration-export type walker on unregistered types - #237

Merged
ASDAlexander77 merged 1 commit into
mainfrom
fix/issue-231-export-null-deref
Jul 15, 2026
Merged

Fix segfault in declaration-export type walker on unregistered types#237
ASDAlexander77 merged 1 commit into
mainfrom
fix/issue-231-export-null-deref

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Summary

  • Fixes the segfault reported in Reproduce browser elements with this compiler #231: on Linux release builds (NDEBUG), the --export=all declaration-export walker in MLIRGenImpl.h dereferenced a null ClassInfo/InterfaceInfo/EnumInfo shared_ptr when a referenced type (e.g. one reachable only from a declare function signature in a .d.ts file) wasn't registered in the corresponding lookup map. The only guard was assert(...), which is compiled out in release builds, so the lookup miss fell straight through to a null-pointer dereference — matching the reporter's gdb backtrace through addClassDeclarationToExport.
  • Replaces the unguarded asserts in addDependancyTypesToExportNoCheck and addTypeDeclarationToExportNoCheck with graceful early-returns, matching the existing safe null-check pattern already used elsewhere (MLIRTypeIterator.h) for the same kind of lookup.

Test plan

  • Compiled MLIRGenClasses.cpp and MLIRGenModule.cpp (both include the modified header) — no new warnings/errors.
  • Reporter's original BrowserLib repro project would be a good end-to-end check once the default lib with Uint8Array/typed-array support is available in this environment.

🤖 Generated with Claude Code

@ASDAlexander77
ASDAlexander77 merged commit 61a0c8c into main Jul 15, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the fix/issue-231-export-null-deref branch July 15, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant