xStreamBufferReset is not interrupt-safe

Hi, I think I may have stumbled into a bug with xStreamBufferReset, and how it interacts with xStreamBufferSendFromISR. Perhaps it’s just a misunderstanding on my, part and if so I think the documentation could probably be a little more clear. Basically, I thought it was always safe to call xStreamBufferReset, but in fact if FromISR functions are used it is not safe, unless interrupts are disabled. Since xStreamBufferReset ultimately clears the underlying stream structure and then re-populates it with interrupts enabled, it is possible for an interrupt to fire while the structure is not in a valid state. If that interrupt tries to access the StreamBuffer, even with one of the fromISR functions that access will fail (and configASSERT). In pseudo-code, my setup is something like this: “` :::c void ISR(void) { … xStreamBufferSendFromISR(/* new byte */); … } void process_bytes(void) { while(1){ /* start with a fresh stream */ xStreamBufferReset(); /* … receive from stream multiple times, continue if error encountered */ return; } “` In my opinion, there should be a specific note in the documenation that xStreamBufferReset is not safe to use with the FromISR functions, or better yet the implementation should be changed such that xStreamBufferReset is safe to use with the FromISR functions. Am I missing something more fundamental? Should I open a support ticket? Thanks for any help!

xStreamBufferReset is not interrupt-safe

Thanks for pointing this out – I have added a crticial section within the xStreamBufferReset() function to make it safe from interrupt access while it is being reset. The code will be checked into the public SVN repo once it has been tested.

xStreamBufferReset is not interrupt-safe

Hi Richard, thanks for your reply. What is the best way for me to get the fix for my current project? Should I wait for a new release to come out? My current work-around is that my code wraps it’s call to xStreamBufferReset() with an interrupt enable/disable, but it would be nice to delegate this responsibility back to the updated xStreamBufferReset().

xStreamBufferReset is not interrupt-safe

That workaround is fine – mine just has the critical section inside the function rather than outside.