-
Notifications
You must be signed in to change notification settings - Fork 37
fix: sesame: look ahead for window releases #1099
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
base: main
Are you sure you want to change the base?
Changes from all commits
8bc1e94
2a02d66
4e6e5c8
cdbef9f
1662f13
c4081bb
071a71e
3c0f495
3a4f974
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -51,6 +51,11 @@ namespace services | |||||||
| receivedMessage.clear(); | ||||||||
| receiveSizeEncoded = 0; | ||||||||
| currentMessageSize = 0; | ||||||||
| nextPeekOverhead = 1; | ||||||||
| peekOverheadPositionIsPseudo = true; | ||||||||
| receivedPeekMessage.clear(); | ||||||||
| receiveSizePeekEncoded = 0; | ||||||||
| currentPeekMessageSize = 0; | ||||||||
|
Comment on lines
51
to
+58
|
||||||||
| receivedDataReader.OnAllocatable([]() {}); | ||||||||
| sendReqestedSize.reset(); | ||||||||
|
|
||||||||
|
|
@@ -75,13 +80,25 @@ namespace services | |||||||
| { | ||||||||
| receiving = true; | ||||||||
|
|
||||||||
| auto& reader = hal::BufferedSerialCommunicationObserver::Subject().Reader(); | ||||||||
|
|
||||||||
| while (true) | ||||||||
| { | ||||||||
| auto data = reader.PeekContiguousRange(receivePeekIndex); | ||||||||
| if (data.empty()) | ||||||||
| break; | ||||||||
| receivePeekIndex += data.size(); | ||||||||
| ReceivedPeekData(data); | ||||||||
| } | ||||||||
|
|
||||||||
| while (receivedDataReader.Allocatable()) | ||||||||
| { | ||||||||
| auto& reader = hal::BufferedSerialCommunicationObserver::Subject().Reader(); | ||||||||
| auto data = reader.ExtractContiguousRange(std::numeric_limits<uint32_t>::max()); | ||||||||
| if (data.empty()) | ||||||||
| break; | ||||||||
| auto dataSize = data.size(); | ||||||||
| ReceivedData(data); | ||||||||
| receivePeekIndex -= dataSize - data.size(); | ||||||||
|
||||||||
| receivePeekIndex -= dataSize - data.size(); | |
| auto consumedBytes = dataSize - data.size(); | |
| receivePeekIndex -= consumedBytes; |
Copilot
AI
Feb 6, 2026
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.
The receivedPeekMessage deque has a max size of 3 bytes (line 93), but messageSize from currentPeekMessageSize can be larger than 3 (line 254 shows it accumulates all data.size()). This creates a mismatch where the reader is constructed with a size that exceeds the actual data available in the deque, which could lead to reading invalid data or undefined behavior.
Copilot
AI
Feb 7, 2026
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.
receivedPeekMessage is capped to 3 bytes, but messageSize tracks the full decoded payload size. Constructing a reader with messageSize greater than the underlying stored bytes can misreport availability and can cause peek handlers to attempt to read beyond what is actually buffered. Consider constructing the peek reader with the actual buffered size (e.g., receivedPeekMessage.size()) or increasing the peek buffer to guarantee messageSize bytes are present.
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.
The new API name
PeekMessagecollides with the common Windows macroPeekMessage(as evidenced by the local#undefworkaround added inservices/echo_console/Main.cpp). This is likely to break other translation units depending on include order. Prefer renaming the API to a less collision-prone identifier (e.g.,PeekReceivedMessage,InspectIncomingMessage,OnMessagePeek) rather than relying on per-file#undeffixes.