Skip to content

[Defaulttype] TypeInfoRegistry: Fix crash at exit in TypeInfoRegistry deleter#6183

Open
fredroy wants to merge 1 commit into
sofa-framework:masterfrom
fredroy:fix_defaulttype_test_typeinfo_exit
Open

[Defaulttype] TypeInfoRegistry: Fix crash at exit in TypeInfoRegistry deleter#6183
fredroy wants to merge 1 commit into
sofa-framework:masterfrom
fredroy:fix_defaulttype_test_typeinfo_exit

Conversation

@fredroy

@fredroy fredroy commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Fix Issue #6182

By Claude:

The root cause is the storage deleter in TypeInfoRegistry::getStorage(), which calls delete info on every stored pointer except NoTypeInfo::Get(). However the registry holds two kinds of pointers:

  • NameOnlyTypeInfo objects it allocates itself with new (in AllocateNewTypeId) ‚ genuinely heap-owned.
  • Pointers registered via Set(), e.g. DataTypeInfoDynamicWrapper<...>::get() (and VirtualTypeInfo<T>::get() used by Data::getValueTypeInfo()), which return function-local statics.

Deleting those static-storage singletons is undefined behavior (invaliddelete + double destruction, since the statics also self-destruct via their own atexit handlers), which triggers the trap. The deleter already special-cased NoTypeInfo::Get() as a singleton but missed that every info registered via Set() is a singleton too.

Fix: Only free what the registry actually allocates:

  • getStorage() now holds non-owning borrowed pointers (no delete-all deleter).
  • A separate getOwnedStorage() (vector<unique_ptr<const AbstractTypeInfo>>)
    owns the NameOnlyTypeInfo objects created in AllocateNewTypeId.

This preserves the leak-free intent of the original deleter (#4838) while never deleting the borrowed static singletons registered through Set().


By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@fredroy fredroy added pr: fix Fix a bug pr: AI-aided Label notifying the reviewers that part or all of the PR has been generated with the help of an AI pr: status to review To notify reviewers to review this pull-request labels Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: AI-aided Label notifying the reviewers that part or all of the PR has been generated with the help of an AI pr: fix Fix a bug pr: status to review To notify reviewers to review this pull-request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant