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 #707, Resolve highest MsgID of 0xFFFF bug #708

Merged

Conversation

skliper
Copy link
Contributor

@skliper skliper commented May 16, 2020

Describe the contribution
Changes Message Key from uint16 to uint32 to avoid rollover and system hang
Fix #707
Fix #414

Testing performed
Steps taken to test the contribution:

  1. Set CFE_PLATFORM_SB_HIGHEST_VALID_MSGID to 0xFFFF
  2. Built (SIMULATION=native) and ran, confirmed startup
  3. CI - https://travis-ci.com/github/skliper/cFS/builds/166553342

Expected behavior changes
Full message ID range available

System(s) tested on

  • Hardware: cFS Dev 3
  • OS: Ubuntu 18.04
  • Versions: Bundle w/ this change

Additional context
Identified/resolved by JSC

Third party code
None

Contributor Info - All information REQUIRED for consideration of pull request
Jacob Hageman - NASA/GSFC

@skliper skliper added bug CCB:Ready Ready for discussion at the Configuration Control Board (CCB) labels May 16, 2020
@skliper skliper added this to the 6.8.0 milestone May 16, 2020
@skliper
Copy link
Contributor Author

skliper commented May 16, 2020

Ping @tngo67

@skliper
Copy link
Contributor Author

skliper commented May 18, 2020

@astrogeco requesting fast-track.

Copy link
Contributor

@CDKnightNASA CDKnightNASA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about just making it "int", as it's only used as an index into an array and would be more compiler optimization friendly?

Copy link
Contributor

@jphickey jphickey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concur that the MsgKey should always be at least the size of MsgId, bigger is OK but smaller is not. However it should also be documented that at least one MsgId value must be considered "reserved" or invalid, and hence it is not possible to use every conceivable MsgId value in your routing table. It is possible that we have another bug lurking in the routing table if we allow a valid route to be configured for CFE_SB_INVALID_MSG_ID

@skliper
Copy link
Contributor Author

skliper commented May 18, 2020

What about just making it "int", as it's only used as an index into an array and would be more compiler optimization friendly?

Minimum size for int is 16 bits. Could go unsigned long? Happy to go either way, I just went fixed size since it was fixed size. Looking at the code in general fixed sizes are used even for iterators... I checked our standard and it doesn't care either way.

@jphickey
Copy link
Contributor

What about just making it "int", as it's only used as an index into an array and would be more compiler optimization friendly?

Minimum size for int is 16 bits. Could go unsigned long? Happy to go either way, I just went fixed size since it was fixed size. Looking at the code in general fixed sizes are used even for iterators... I checked our standard and it doesn't care either way.

I agree, in this case the fundamental issue is that MsgKey didn't have enough bits. The algorithm requires that the key has enough bits to hold at least (1 + CFE_PLATFORM_SB_HIGHEST_VALID_MSGID). This means we need to ensure it actually has 32 bits in it, if we want to support a highest msgid of 0xFFFF or greater.

I think in the original implementation, there was an assumption that if the lookup table grew beyond 2^16 entries, it would use some other more memory efficient algorithm like a hash table, rather than a direct lookup table. Even at 2^16 this is probably wasting a good chunk of memory.

Changes Message Key from uint16 to uint32 to avoid rollover
@skliper
Copy link
Contributor Author

skliper commented May 19, 2020

Added note about the table being + 1.

@skliper skliper linked an issue May 19, 2020 that may be closed by this pull request
@skliper
Copy link
Contributor Author

skliper commented May 20, 2020

@astrogeco please fast track this one

@astrogeco
Copy link
Contributor

@astrogeco please fast track this one

Will merge right after CCB

@astrogeco astrogeco changed the base branch from master to integration-candidate May 20, 2020 16:17
@astrogeco astrogeco added CCB:Approved Indicates code review and approval by community CCB and removed CCB:Ready Ready for discussion at the Configuration Control Board (CCB) labels May 20, 2020
@astrogeco astrogeco merged commit 4d78023 into nasa:integration-candidate May 20, 2020
@skliper skliper deleted the fix707-msgkey-type-bug branch June 5, 2020 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug CCB:Approved Indicates code review and approval by community CCB CCB:FastTrack
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting highest valid message ID's to 0xFFFF hangs cfe Suggested upper limit value creates infinite loop
4 participants