Skip to content

fix: release TlmLinearChan storage in deinit - #48

Open
FAROTECH wants to merge 3 commits into
fprime-community:mainfrom
FAROTECH:fix/tlm-linear-chan-deinit
Open

FAROTECH wants to merge 3 commits into
fprime-community:mainfrom
FAROTECH:fix/tlm-linear-chan-deinit

Conversation

@FAROTECH

Copy link
Copy Markdown

Fixes #44

Summary

TlmLinearChan currently returns allocator-backed storage from its C++ destructor. Because the allocator is borrowed from outside the component, that makes cleanup depend on C++ object destruction order.

This change moves the TlmEntry destruction and allocator deallocate() call into TlmLinearChan::deinit(), which is invoked during F Prime topology teardown before static/global destruction. The component destructor is left resource-neutral.

The cleanup order is:

  1. destroy the in-place TlmEntry objects;
  2. return the raw storage through the borrowed allocator;
  3. clear the stored resource state;
  4. call TlmLinearChanComponentBase::deinit().

The old unit-test comment requiring the allocator member to be declared before the component is removed because that destruction-order workaround is no longer required.

Regression coverage

Adds DeinitReleasesAllocatorStorage, using a tracking allocator to verify that:

  • no deallocation happens before deinit();
  • exactly one deallocation happens during deinit();
  • the memory ID and pointer match the original allocation;
  • component destruction does not deallocate the storage a second time.

Validation

Validated locally against:

  • fprime-baremetal: 14e75f7bce204d058d44a463620b65759bbd6187
  • F Prime: 4e1f495726ba41f3b674fe6e0efe8a49c8894a0e
  • googletest: 58d77fa8070e8cec2dc1ed015d66b454c8d78850

Results:

  • fprime-util generate --ut: PASS
  • fprime-util build --ut: PASS
  • TlmLinearChan unit tests: 5/5 PASS
  • broader relevant fprime-baremetal tests: 3/3 PASS
  • git diff --check: PASS

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.

Invalid use of deallocate in TlmLinearChan destructor

1 participant