Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid assert on BufferManager destruction #1383

Merged
merged 1 commit into from
Apr 12, 2022

Conversation

Kronos3
Copy link
Contributor

@Kronos3 Kronos3 commented Apr 12, 2022

Originating Project/Creator
Affected Component Svc/BufferManager
Affected Architectures(s) All
Related Issue(s)
Has Unit Tests (y/n)
Builds Without Errors (y/n)
Unit Tests Pass (y/n)
Documentation Included (y/n)

Change Description

Avoid calling BufferManager::cleanup() if BufferManager::setup() was never called.

Rationale

Relevant when FSW exits early (before initialization). The BufferManager destructor will be called and either an assertion will trip saying m_allocator is NULL or segfault if there is no assertion hook set up.

FW_ASSERT(this->m_allocator);
if (not this->m_cleaned) {
// walk through Fw::Buffer instances and delete them
for (NATIVE_UINT_TYPE entry = 0; entry < this->m_numStructs; entry++) {
this->m_buffers[entry].buff.~Buffer();
}
this->m_cleaned = true;
// release memory
this->m_allocator->deallocate(this->m_memId,this->m_buffers);

Co-authored-by: Andrei Tumbar <andreitumbar@gmail.com>
@LeStarch LeStarch requested a review from timcanham April 12, 2022 17:06
@LeStarch LeStarch merged commit b306183 into nasa:devel Apr 12, 2022
@Kronos3 Kronos3 deleted the tumbar-buffer-manager-sefault branch April 13, 2022 03:43
@Kronos3 Kronos3 restored the tumbar-buffer-manager-sefault branch April 25, 2022 03:45
@Kronos3 Kronos3 deleted the tumbar-buffer-manager-sefault branch April 25, 2022 03:46
LeStarch pushed a commit that referenced this pull request Jun 29, 2022
Co-authored-by: Andrei Tumbar <andreitumbar@gmail.com>

Co-authored-by: Andrei Tumbar <andrei.tumbar@jpl.nasa.gov>
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.

3 participants