Skip to content

Fix async SignalFuture panic when object is freed before exit flag - #1648

Merged
Bromeon merged 2 commits into
masterfrom
bugfix/async-shutdown-poll-panic
Jun 28, 2026
Merged

Fix async SignalFuture panic when object is freed before exit flag#1648
Bromeon merged 2 commits into
masterfrom
bugfix/async-shutdown-poll-panic

Conversation

@Bromeon

@Bromeon Bromeon commented Jun 27, 2026

Copy link
Copy Markdown
Member

Previously, the engine-exiting flag was only checked when the signal resolver was dropped. But during a real shutdown, the signal object is often freed before that flag is set. The resolver then marks the future as dead and wakes it, so the drop-time check is too late, and the next poll panics with "the signal object of a SignalFuture was freed".

Now the flag is also checked at poll time: a dead SignalFuture polled while the engine is exiting parks silently (and is dropped during cleanup) instead of panicking. FallibleSignalFuture is unchanged and still resolves to an error.

Adds an integration test for the freed-before-flag ordering.

Closes #1624.

@Bromeon Bromeon added bug c: async Everything related to async tasks/signals labels Jun 27, 2026
@GodotRust

Copy link
Copy Markdown

API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1648

Bromeon added 2 commits June 28, 2026 10:03
…t flag

Previously, the engine-exiting flag was only checked when the signal
resolver was dropped. But during a real shutdown, the signal object is
often freed before that flag is set. The resolver then marks the future
as dead and wakes it, so the drop-time check is too late, and the next
poll panics with "the signal object of a SignalFuture was freed".

Now the flag is also checked at poll time: a dead `SignalFuture` polled
while the engine is exiting parks silently (and is dropped during
cleanup) instead of panicking. `FallibleSignalFuture` is unchanged and
still resolves to an error.

Adds an integration test for the freed-before-flag ordering.
@Bromeon
Bromeon force-pushed the bugfix/async-shutdown-poll-panic branch from 999a419 to 73fed1f Compare June 28, 2026 08:27
@Bromeon
Bromeon added this pull request to the merge queue Jun 28, 2026
Merged via the queue into master with commit d5b34ee Jun 28, 2026
17 checks passed
@Bromeon
Bromeon deleted the bugfix/async-shutdown-poll-panic branch June 28, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug c: async Everything related to async tasks/signals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

godot::task::spawn tasks are not safely cancelled on application exit

2 participants