-
Notifications
You must be signed in to change notification settings - Fork 7.2k
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
Ringbuffer timeouts in certain cases (IDFGH-5624) #7344
Comments
What is your esp-idf version? (git describe --tags) |
It's dirty due to some accidental saves, but |
Fix tracking free space. Fix a number of potential underflow issues, as well as a few incorrect comments. Don't round up data size for the last chunk. Fixes espressif#7344
Fix tracking free space. Fix a number of potential underflow issues, as well as a few incorrect comments. Don't round up data size for the last chunk. Fixes espressif#7344
Fix tracking free space. Fix a number of potential underflow issues, as well as a few incorrect comments. Don't round up data size for the last chunk. Fixes espressif#7344
You have uint8_t data[9], but pass 10 in above code. |
It's a mistake on my part but doesn't matter. I'll fix the comment |
@bugadani I've confirmed that this indeed a bug. The source of the issue is in I'll push a fix for this issue shortly. For now, to work around this issue you can replace the following lines of From... //Check if pucRead requires wrap around
if ((pxRingbuffer->pucTail - pxRingbuffer->pucRead) < rbHEADER_SIZE) {
pxRingbuffer->pucRead = pxRingbuffer->pucHead;
} To //Check if pucRead requires wrap around
if (((ItemHeader_t *)pxRingbuffer->pucRead)->uxItemFlags & rbITEM_DUMMY_DATA_FLAG || //Next item is a dummy
((pxRingbuffer->pucTail - pxRingbuffer->pucRead) < rbHEADER_SIZE)) { //Remaining space cannot fit a header
pxRingbuffer->pucRead = pxRingbuffer->pucHead; //Wrap pucREAD around
} |
Good catch, thanks! |
Test on v4.4-dev-3235-g3e370c429624 Backtrace:0x40081bc6:0x3ffb09900x40089361:0x3ffb09b0 0x4008ff35:0x3ffb09d0 0x400886c7:0x3ffb0af0 0x400891bd:0x3ffb0b10 0x4008341a:0x3ffb0b30 0x40082a11:0x3ffb0ba0 0x4000bfed:0x3ffbbf70 0x4008cb7a:0x3ffbbf80 0x400fa16e:0x3ffbbfa0 0x400fa2a1:0x3ffbbfd0 0x400fa825:0x3ffbc020 0x400ebc78:0x3ffbc050 0x400eda3c:0x3ffbc080 0x400e4e23:0x3ffbc0b0 0x400e5691:0x3ffbc160 0x400d9322:0x3ffbc210 0x40199803:0x3ffbc5b0 0x40089361: esp_system_abort at /home/axel/esp/esp-idf/components/esp_system/esp_system.c:129 0x4008ff35: __assert_func at /home/axel/esp/esp-idf/components/newlib/assert.c:85 0x400886c7: prvReturnItemDefault at /home/axel/esp/esp-idf/components/esp_ringbuf/ringbuf.c:597 (discriminator 1) 0x400891bd: vRingbufferReturnItemFromISR at /home/axel/esp/esp-idf/components/esp_ringbuf/ringbuf.c:1281 0x4008341a: uart_rx_intr_handler_default at /home/axel/esp/esp-idf/components/driver/uart.c:826 0x40082a11: _xt_lowint1 at /home/axel/esp/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:1111 0x4008cb7a: vPortExitCritical at /home/axel/esp/esp-idf/components/freertos/port/xtensa/port.c:447 0x400fa16e: uart_enable_tx_intr at /home/axel/esp/esp-idf/components/driver/uart.c:580 (discriminator 2) 0x400fa2a1: uart_tx_all at /home/axel/esp/esp-idf/components/driver/uart.c:1169 0x400fa825: uart_tx_all at /home/axel/esp/esp-idf/components/driver/uart.c:1144 |
@Dazza0 |
I test it using pppos client, the uart driver uses the ringbuffer and I always hit below assertion if I change the code as you suggested. ps. It works if I don't change the code as you suggested. |
Hi @AxelLin, thanks for the feedback. We are still working on this issue at the moment and trying to figure out what the problem with the workaround is. |
Hi @AxelLin , @bugadani , I'll make a fix for this. In the interim, you could test your code by making the following changes in From:
To
|
I still hit the same assertion with below modified code:
|
Hi @AxelLin,
Please keep the |
It works if only update the prvGetCurMaxSizeNoSplit() function. I have some suggestions:
|
Thanks for confirming @AxelLin and also for your suggestions. This scenario is only hit when the free space left in the buffer is less than the size of a no-split header (i.e, |
@sudeep-mohanty |
…and resulted in incorrect free size for no-split/allow-split buffers This commit fixes a bug in no-split and allow-split ring buffers free buffer size calculation. When the free size available in the buffers less than the size of one item header, the function prvGetCurMaxSizeNoSplit/AllowSplit() incorrectly returned the maxItemSize instead of 0. This is due to the comparision between a negative and a positive value where both operands are treated as unsigned during the comparision operation, thereby treating the negative operand as a large integer. Also added new unit tests to test buffer-full and almost-full conditions where this scenario is likely to be hit. Closes #7344 Closes #7371
…and resulted in incorrect free size for no-split/allow-split buffers This commit fixes a bug in no-split and allow-split ring buffers free buffer size calculation. When the free size available in the buffers less than the size of one item header, the function prvGetCurMaxSizeNoSplit/AllowSplit() incorrectly returned the maxItemSize instead of 0. This is due to the comparision between a negative and a positive value where both operands are treated as unsigned during the comparision operation, thereby treating the negative operand as a large integer. Also added new unit tests to test buffer-full and almost-full conditions where this scenario is likely to be hit. Closes #7344 Closes #7371
Just remind that v4.3 branch still does not include this fix. |
@AxelLin Thanks for the attention, we have back ported this fix to 4.3, but still under internal reviewing, will sync up here once the fix is available on GitHub. |
…and resulted in incorrect free size for no-split/allow-split buffers This commit fixes a bug in no-split and allow-split ring buffers free buffer size calculation. When the free size available in the buffers less than the size of one item header, the function prvGetCurMaxSizeNoSplit/AllowSplit() incorrectly returned the maxItemSize instead of 0. This is due to the comparision between a negative and a positive value where both operands are treated as unsigned during the comparision operation, thereby treating the negative operand as a large integer. Also added new unit tests to test buffer-full and almost-full conditions where this scenario is likely to be hit. Closes #7344 Closes #7371
…and resulted in incorrect free size for no-split/allow-split buffers This commit fixes a bug in no-split and allow-split ring buffers free buffer size calculation. When the free size available in the buffers less than the size of one item header, the function prvGetCurMaxSizeNoSplit/AllowSplit() incorrectly returned the maxItemSize instead of 0. This is due to the comparision between a negative and a positive value where both operands are treated as unsigned during the comparision operation, thereby treating the negative operand as a large integer. Also added new unit tests to test buffer-full and almost-full conditions where this scenario is likely to be hit. Closes #7344 Closes #7371
…and resulted in incorrect free size for no-split/allow-split buffers This commit fixes a bug in no-split and allow-split ring buffers free buffer size calculation. When the free size available in the buffers less than the size of one item header, the function prvGetCurMaxSizeNoSplit/AllowSplit() incorrectly returned the maxItemSize instead of 0. This is due to the comparision between a negative and a positive value where both operands are treated as unsigned during the comparision operation, thereby treating the negative operand as a large integer. Also added new unit tests to test buffer-full and almost-full conditions where this scenario is likely to be hit. Closes #7344 Closes #7371
I was experiencing some weird issues with regards to the Ringbuffer api, so I wrote a few tests to reproduce my problem. Both of the following tests fail on the "Timeout" assert. The issue is sensitive to the buffer size, the data size and I also had to insert data with different sizes.
Original, more complex examples - Click to expand!
Edit: I've made a simpler test case:
The text was updated successfully, but these errors were encountered: