Skip to content

Commit 6800b12

Browse files
committed
Fix issue with free rtos execute sync
Stop handle_sync_func_call removing the worker. Depending on thread priority this can occur after the memory has gone out of scope in async_context_freertos_execute_sync. Fixes #1962
1 parent bd5523c commit 6800b12

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/rp2_common/pico_async_context/async_context_freertos.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ static void handle_sync_func_call(async_context_t *context, async_when_pending_w
188188
sync_func_call_t *call = (sync_func_call_t *)worker;
189189
call->rc = call->func(call->param);
190190
xSemaphoreGive(call->sem);
191-
async_context_remove_when_pending_worker(context, worker);
192191
}
193192

194193
uint32_t async_context_freertos_execute_sync(async_context_t *self_base, uint32_t (*func)(void *param), void *param) {
@@ -202,6 +201,7 @@ uint32_t async_context_freertos_execute_sync(async_context_t *self_base, uint32_
202201
async_context_add_when_pending_worker(self_base, &call.worker);
203202
async_context_set_work_pending(self_base, &call.worker);
204203
xSemaphoreTake(call.sem, portMAX_DELAY);
204+
async_context_remove_when_pending_worker(self_base, &call.worker);
205205
vSemaphoreDelete(call.sem);
206206
return call.rc;
207207
}

0 commit comments

Comments
 (0)