-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
CircularEventBufferWrapper::GetNextBuffer does not seem to handle lookahead via reader copies correctly #9575
Comments
@robszewczyk @yunhanw-google as part of implementing eventing on the server side, please validate this. |
for CircularEventBufferWrapper, I guess your concern is CircularEventBufferWrapper may modify the CHIPCircularTLVBuffer or TLVBackingStore state by GetNextBuffer, When reviewing the logic, |
Good catch. Looks like it indeed does not. Might be good to have a const method that gets called from |
agree, actually GetNextBuffer is overriable method, for TLVReader that use CHIP_ERROR TLVPacketBufferBackingStore::GetNextBuffer(chip::TLV::TLVReader & reader, const uint8_t *& bufStart, uint32_t & bufLen), it do modify the state. |
would close it now. let me if any further concern, many thanks. |
Problem
A typical pattern we have in our code is that a new TLV reader (
B
) is initialized with an existing TLV reader (A
), and then is advanced in various ways to figure out something about the state of the TLV thatA
has not read yet.When
A
is backed by aTLVBackingStore
,B
ends up using the exact same backing store object. This means that the backing storeGetNextBuffer
must not modify any state of the store for this setup to work when the read-ahead crosses a buffer boundary. Otherwise advancingB
will change the state, and then going back toA
and trying to read the data will not get the right data.Proposed Solution
Need to either fix
CircularEventBufferWrapper
to not mutate any state or carefully audit whether any of the readers that useCircularEventBufferWrapper
are ever used (including internally withinTLVReader
, e.g. viaTLVReader::FindElementWithTag
) in the above-described pattern.@yunhanw-google @mrjerryjohns
The text was updated successfully, but these errors were encountered: