Skip to content

Fix a race condition in context_destroy#2277

Open
pguyot wants to merge 1 commit intoatomvm:release-0.7from
pguyot:w17/fix-race-condition-context_destroy-timeout
Open

Fix a race condition in context_destroy#2277
pguyot wants to merge 1 commit intoatomvm:release-0.7from
pguyot:w17/fix-race-condition-context_destroy-timeout

Conversation

@pguyot
Copy link
Copy Markdown
Collaborator

@pguyot pguyot commented Apr 20, 2026

Another scheduler may be running update_timer_list while the context was being destroyed. Force synchronization by inconditionally calling scheduler_cancel_timeout which holds the spinlock and cancel any timeout before the process is removed from the process table.

This seems to fix some crashes on macOS under heavy load.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

Another scheduler may be running `update_timer_list` while the context was
being destroyed. Force synchronization by inconditionally calling
`scheduler_cancel_timeout` which holds the spinlock and cancel any timeout
before the process is removed from the process table.

This seems to fix some crashes on macOS under heavy load.

Signed-off-by: Paul Guyot <pguyot@kallisys.net>
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.

3 participants