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

Fix bug in Fw::Buffer #2136

Merged
merged 2 commits into from
Jul 18, 2023
Merged

Fix bug in Fw::Buffer #2136

merged 2 commits into from
Jul 18, 2023

Conversation

bocchino
Copy link
Collaborator

@bocchino bocchino commented Jul 17, 2023

The copy constructor for Fw::Buffer was causing an assertion failure when copying an invalid buffer. I noticed this because I was writing unit tests that passed invalid buffers around, and I saw the assertion failure.

This patch fixes the issue.

Note: For correctness, I had to replace FW_ASSERT(p) with FW_ASSERT(p != nullptr) in one place. Otherwise we are assuming that nullptr == 0 which is not guaranteed to be true. We should make this change consistently throughout the framework, but I made the minimal change for now.

@bocchino bocchino requested review from LeStarch and timcanham July 17, 2023 22:55
@timcanham
Copy link
Collaborator

I guess this means that the new buffer is now invalid?

@bocchino
Copy link
Collaborator Author

I think so. I think a buffer should be considered invalid if the pointer is nullptr or the size is zero.

Note the SDD implies that if pointer == nullptr then size should be zero. We could add an assertion for that.

@bocchino
Copy link
Collaborator Author

But then it should be an invariant of Fw::Buffer that's checked everywhere, not just in this one place.

@bocchino
Copy link
Collaborator Author

For this PR I made the minimal change to avoid an assertion failure that I thought shouldn't be happening.

@LeStarch
Copy link
Collaborator

This change seems correct to me.

@LeStarch LeStarch merged commit f91f5c2 into nasa:devel Jul 18, 2023
thomas-bc pushed a commit that referenced this pull request Aug 4, 2023
* Fix bug in Fw::Buffer

* Revise null pointer check in Serializable.cpp
thomas-bc added a commit that referenced this pull request Aug 4, 2023
@bocchino bocchino deleted the fw-buffer branch October 9, 2023 23:01
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