Skip to content

Fix heap use-after-free in shared object loading#835

Merged
mcserep merged 1 commit intoEricsson:masterfrom
barnabasdomozi:fix_heap_use_after_free
Mar 3, 2026
Merged

Fix heap use-after-free in shared object loading#835
mcserep merged 1 commit intoEricsson:masterfrom
barnabasdomozi:fix_heap_use_after_free

Conversation

@barnabasdomozi
Copy link
Collaborator

The bug was first observed in the CI pipeline, which occasionally failed with a free(): invalid pointer error. Building the project with AddressSanitizer enabled revealed a heap use-after-free issue.
It was introduced by Python plugin PR
(commit f69d6db), which modified how plugin shared objects are loaded. If both cppparser and cxxmetricsparser plugins are loaded with dlopen using the RTLD_GLOBAL flag, the global objects in these shared libraries conflict on unload, causing a use-after-free error.
As a solution, we reverted to the previous behavior: all shared objects are loaded with RTLD_NOW by default, and only the pythonparser shared object is loaded with RTLD_GLOBAL.

The bug was first observed in the CI pipeline, which
occasionally failed with a free(): invalid pointer error.
Building the project with AddressSanitizer enabled revealed
a heap use-after-free issue.
It was introduced by Python plugin PR
(commit f69d6db), which modified
how plugin shared objects are loaded. If both cppparser and
cxxmetricsparser plugins are loaded with dlopen using the RTLD_GLOBAL
flag, the global objects in these shared libraries conflict
on unload, causing a use-after-free error.
As a solution, we reverted to the previous behavior:
all shared objects are loaded with RTLD_NOW by default, and only the
pythonparser shared object is loaded with RTLD_GLOBAL.
@barnabasdomozi barnabasdomozi requested a review from mcserep March 1, 2026 11:10
@barnabasdomozi barnabasdomozi added Plugin: C++ Issues related to the parsing and presentation of C++ projects. Plugin: Python Issues related to the parsing and presentation of Python projects. Target: Parser labels Mar 1, 2026
@mcserep mcserep added this to the Upcoming Release milestone Mar 3, 2026
@mcserep mcserep added this to Roadmap Mar 3, 2026
@github-project-automation github-project-automation bot moved this to In progress in Roadmap Mar 3, 2026
Copy link
Collaborator

@mcserep mcserep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for investigating and fixing this!

@mcserep mcserep merged commit 3755e3f into Ericsson:master Mar 3, 2026
14 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in Roadmap Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Kind: Bug ⚠️ Plugin: C++ Issues related to the parsing and presentation of C++ projects. Plugin: Python Issues related to the parsing and presentation of Python projects. Target: Parser

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants