]> granicus.if.org Git - esp-idf/commit
esp_timer: do not allow deleting timers while callbacks are dispatched
authorIvan Grokhotkov <ivan@espressif.com>
Wed, 19 Dec 2018 07:53:50 +0000 (15:53 +0800)
committerAngus Gratton <gus@projectgus.com>
Wed, 2 Jan 2019 09:01:26 +0000 (20:01 +1100)
commit1937bc2bd765a2192152c351f5fb93333b73b678
tree8227c29bd8012dc6e22545dd1b2b8aea3daa5beb
parenta18f92b09b2e87a3c0424d92991e8898d6b8bc8d
esp_timer: do not allow deleting timers while callbacks are dispatched

timer_process_alarm function of esp_timer holds a spinlock for the
entire duration of its operation, except for the time when timer
callback function is called. It is possible that when
timer_process_alarm releases the spinlock, a higher priority task may
run and delete the timer. Then the execution will return to
timer_process_alarm, and this will either cause a crash, or undesired
execution of callback after the timer has been stopped or deleted.

To solve this problem, add a mutex which will prevent deletion of timers
while callbacks are being dispatched.
components/esp32/esp_timer.c