-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 ComQueue Does Not Deallocate Buffers on Overflow #2853
Conversation
@@ -139,7 +139,11 @@ | |||
// Ensure that the port number of buffQueueIn is consistent with the expectation | |||
FW_ASSERT(portNum >= 0 && portNum < BUFFER_PORT_COUNT, portNum); | |||
FW_ASSERT(queueNum < TOTAL_PORT_COUNT); | |||
this->enqueue(queueNum, QueueType::BUFFER_QUEUE, reinterpret_cast<const U8*>(&fwBuffer), sizeof(Fw::Buffer)); | |||
bool status = |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
// ---------------------------------------------------------------------- | ||
// Private helper methods | ||
// ---------------------------------------------------------------------- | ||
|
||
void ComQueue::enqueue(const FwIndexType queueNum, QueueType queueType, const U8* data, const FwSizeType size) { | ||
bool ComQueue::enqueue(const FwIndexType queueNum, QueueType queueType, const U8* data, const FwSizeType size) { |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
// ---------------------------------------------------------------------- | ||
// Private helper methods | ||
// ---------------------------------------------------------------------- | ||
|
||
void ComQueue::enqueue(const FwIndexType queueNum, QueueType queueType, const U8* data, const FwSizeType size) { | ||
bool ComQueue::enqueue(const FwIndexType queueNum, QueueType queueType, const U8* data, const FwSizeType size) { |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
// ---------------------------------------------------------------------- | ||
// Private helper methods | ||
// ---------------------------------------------------------------------- | ||
|
||
void ComQueue::enqueue(const FwIndexType queueNum, QueueType queueType, const U8* data, const FwSizeType size) { | ||
bool ComQueue::enqueue(const FwIndexType queueNum, QueueType queueType, const U8* data, const FwSizeType size) { |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
// Enqueue the given message onto the matching queue. When no space is available then emit the queue overflow event, | ||
// set the appropriate throttle, and move on. Will assert if passed a message for a depth 0 queue. | ||
const FwSizeType expectedSize = (queueType == QueueType::COM_QUEUE) ? sizeof(Fw::ComBuffer) : sizeof(Fw::Buffer); | ||
const FwIndexType portNum = queueNum - ((queueType == QueueType::COM_QUEUE) ? 0 : COM_PORT_COUNT); | ||
bool rvStatus = true; |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
// ---------------------------------------------------------------------- | ||
// Private helper methods | ||
// ---------------------------------------------------------------------- | ||
|
||
void ComQueue::enqueue(const FwIndexType queueNum, QueueType queueType, const U8* data, const FwSizeType size) { | ||
bool ComQueue::enqueue(const FwIndexType queueNum, QueueType queueType, const U8* data, const FwSizeType size) { |
Check notice
Code scanning / CodeQL
Long function without assertion Note
@@ -139,7 +139,11 @@ | |||
// Ensure that the port number of buffQueueIn is consistent with the expectation | |||
FW_ASSERT(portNum >= 0 && portNum < BUFFER_PORT_COUNT, portNum); | |||
FW_ASSERT(queueNum < TOTAL_PORT_COUNT); | |||
this->enqueue(queueNum, QueueType::BUFFER_QUEUE, reinterpret_cast<const U8*>(&fwBuffer), sizeof(Fw::Buffer)); | |||
bool status = | |||
this->enqueue(queueNum, QueueType::BUFFER_QUEUE, reinterpret_cast<const U8*>(&fwBuffer), sizeof(Fw::Buffer)); |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
// ---------------------------------------------------------------------- | ||
|
||
void ComQueue::buffQueueIn_overflowHook(FwIndexType portNum, Fw::Buffer& fwBuffer) { | ||
this->deallocate_out(portNum, fwBuffer); |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are several things that need to be fixed:
- In the com queue function, we should explicitly discard the new enqueue status with
(void) this->enqueue...
- I don't see any tests proving that the drop function is called on overflow. Can we add those.
- CI needs to pass
@@ -131,15 +131,19 @@ | |||
void ComQueue::comQueueIn_handler(const NATIVE_INT_TYPE portNum, Fw::ComBuffer& data, U32 context) { | |||
// Ensure that the port number of comQueueIn is consistent with the expectation | |||
FW_ASSERT(portNum >= 0 && portNum < COM_PORT_COUNT, portNum); | |||
this->enqueue(portNum, QueueType::COM_QUEUE, reinterpret_cast<const U8*>(&data), sizeof(Fw::ComBuffer)); | |||
(void)this->enqueue(portNum, QueueType::COM_QUEUE, reinterpret_cast<const U8*>(&data), sizeof(Fw::ComBuffer)); |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
// Hook implementations for typed async input ports | ||
// ---------------------------------------------------------------------- | ||
|
||
void ComQueue::buffQueueIn_overflowHook(FwIndexType portNum, Fw::Buffer& fwBuffer) { |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
Skipping known ci failure. Nice work! |
Change Description
Fix potential memory leak when a sent
Fw::Buffer
overflowsComQueue
.Fw.BufferSend
deallocate
port toComQueue
buffQueueIn
port fromdrop
tohook
ComQueue::enqueue()
Fw::Buffer
is now deallocated on queue overflowUT_AUTO_HELPERS
inComQueue
UT buildComQueue
UTs