Skip to content

Concurrency safety fixes#452

Merged
stintel merged 4 commits intomainfrom
fix/concurrency_safety
Feb 12, 2026
Merged

Concurrency safety fixes#452
stintel merged 4 commits intomainfrom
fix/concurrency_safety

Conversation

@stintel
Copy link
Collaborator

@stintel stintel commented Feb 12, 2026

No description provided.

We're accessing the notify_active pointer from multiple contexts: WS
callback, button cancel callback, and notify_task. Without
synchronization, a task could dereference the pointer while another task
is freeing it, causing a use-after-free.

Add a mutex guard to prevent this.

Reported-by: Claude Opus 4.6 <noreply@anthropic.com>
notify_active and nd point to the same memory. Freeing nd before
clearing notify_active leaves a dangling pointer that another task
could dereference. Clear the pointer first to prevent use-after-free.

Reported-by: Claude Opus 4.6 <noreply@anthropic.com>
The cancel button could be pressed after the notify task has already
finished and cleared notify_active. Check for NULL to avoid a null
pointer dereference.

Reported-by: Claude Opus 4.6 <noreply@anthropic.com>
The volatile keyword only tells the compiler to not cache the variable
in a register, but to always read from memory. It does not guarantee
visibility across cores, memory ordering, or atomicity. As the ESP32-S3
is dual-core, use _Atomic to ensure correctness when accessing these
variables from different tasks.

Reported-by: Claude Opus 4.6 <noreply@anthropic.com>
@stintel stintel merged commit b87acae into main Feb 12, 2026
9 checks passed
@stintel stintel deleted the fix/concurrency_safety branch February 12, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant