Timer race condition #243
No reviewers
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk!243
Loading…
Reference in a new issue
No description provided.
Delete branch "timer-race-condition"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
fixes #195
@ -221,0 +231,4 @@}int issue_195_test(void) {PICOTEST_START_SECTION("Issue #195 race condition - without fix may hang on gcc 10.2.1 release builds");Apologies if this is a stupid question, but this seems to be checking the return from
issue_195_test()but AFAICT that function will only everreturn 0? Was that function supposed toreturn 1if the delta betweenexpected_countandissue_195_counterwas too big?@ -221,0 +231,4 @@}int issue_195_test(void) {PICOTEST_START_SECTION("Issue #195 race condition - without fix may hang on gcc 10.2.1 release builds");nope; there are macros
@ -221,0 +231,4 @@}int issue_195_test(void) {PICOTEST_START_SECTION("Issue #195 race condition - without fix may hang on gcc 10.2.1 release builds");Perhaps I'm being really stupid, but I can see that
issue_195_test()has aPICOTEST_START_SECTIONmacro which setspicotest_error_code = 0and there's aPICOTEST_END_SECTIONmacro which checksif (picotest_error_code != 0), but I can't tell where (inissue_195_test())picotest_error_codeactually gets modified 😕@ -221,0 +231,4 @@}int issue_195_test(void) {PICOTEST_START_SECTION("Issue #195 race condition - without fix may hang on gcc 10.2.1 release builds");the convention i am propagating is that tests return 0 on success or otherwise on failure which is what the macros do in general. Yes there is no actual check here atm (as it causes a hang in the failure case)... it does not matter
@ -221,0 +231,4 @@}int issue_195_test(void) {PICOTEST_START_SECTION("Issue #195 race condition - without fix may hang on gcc 10.2.1 release builds");Oh, that's the bit I was missing. Sorry for pestering you!
So the failure mode was an alarm firing at the point we were in the critical section setting an immediately-expiring timer on the same alarm, and getting dropped as a result?
setting an immediately expiring timer when there was already a timer that had fired but not yet been serviced (because we were under lock)
note it also requires a mix of timers adding in IRQ (i.e. repeating) and non IRQ contexts (we already had a test which created a huge number of timers with random timeouts and makes sure they all happen and in the right order - just none of those repeated)