Closed Bug 1746533 Opened 2 years ago Closed 2 years ago

Crash in [@ core::option::expect_failed | <async_task::task::Task<T> as core::future::future::Future>::poll] with "task has failed"

Categories

(Core :: XPCOM, defect)

defect

Tracking

()

RESOLVED FIXED
98 Branch
Tracking Status
firefox-esr91 --- unaffected
firefox95 --- unaffected
firefox96 --- unaffected
firefox97 --- wontfix
firefox98 --- fixed

People

(Reporter: mccr8, Assigned: nika)

References

(Regression)

Details

(Keywords: crash, regression)

Crash Data

Attachments

(2 files)

Crash report: https://crash-stats.mozilla.org/report/index/6777247c-f8c7-4f6e-8598-8a64f0211210

MOZ_CRASH Reason: task has failed

Top 10 frames of crashing thread:

0 XUL RustMozCrash mozglue/static/rust/wrappers.cpp:18
1 XUL mozglue_static::panic_hook mozglue/static/rust/lib.rs:91
2 XUL core::ops::function::Fn::call library/core/src/ops/function.rs:70
3 XUL std::panicking::rust_panic_with_hook library/std/src/panicking.rs:628
4 XUL std::panicking::begin_panic_handler::{{closure}} library/std/src/panicking.rs:521
5 XUL std::sys_common::backtrace::__rust_end_short_backtrace library/std/src/sys_common/backtrace.rs:139
6 XUL rust_begin_unwind library/std/src/panicking.rs:517
7 XUL core::panicking::panic_fmt library/core/src/panicking.rs:100
8 XUL core::panicking::panic_display library/core/src/panicking.rs:64
9 XUL core::option::expect_failed library/core/src/option.rs:1638

This stack is not very informative, but this error message was added in bug 1739727. The first build with this crash is 20211208095339, which does line up with the landing of this bug. This might just be a signature change for Rust task failure crashes.

Set release status flags based on info from the regressing bug 1739727

Needinfo based on comment 1, :nika can you look into this or forward the needinfo? Thanks!

Flags: needinfo?(nika)

This helps fix a crash being caused by the runnable created by the
moz_task library being dropped when a dispatch to a background thread
fails. The async_task library was written assuming that panics are
recoverable, and doesn't provide a way to recover from task cancellation
other than handling panics, which are hard crashes in Gecko.

To work around this issue for now, this patch wraps the
async_task::Runnable object in a ManuallyDrop to prevent it being
destroyed if the runnable is not executed, and replaces the crash with a
debug-only assertion closer to the source of the issue.

In the future we may want to be able to handle cancelled tasks better,
but we'll need to make modifications to async_task to make that
happen.

Assignee: nobody → nika
Status: NEW → ASSIGNED
Has Regression Range: --- → yes

I hit this relatively often on macOS fwiw.

I have filed and gotten merged a change to the async_task crate to allow us to manually handle cancelled tasks (https://github.com/smol-rs/async-task/pull/21). A new release hasn't been cut yet, but I can add a git dependency for the updated version.

Flags: needinfo?(nika)

This version adds a new FallibleTask wrapper type which allows polling the
task without panicking.

Attachment #9258114 - Attachment description: Bug 1746533 - Ensure the task isn't cancelled if dispatch failed, r=#xpcom-reviewers → Bug 1746533 - Part 2: Use the fallible Poll implementation in moz_task, r=emilio
Pushed by nlayzell@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/aeec2a03935f
Part 1: Use custom vendored version of async-task, r=emilio
https://hg.mozilla.org/integration/autoland/rev/f5f803c35e09
Part 2: Use the fallible Poll implementation in moz_task, r=emilio
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 98 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: