segfault in async state drop glue: `Arc` field dropped while zeroed

Open
#270 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust
Domain
compilers

Research direction

Start from the async-state lowering code that generates drop glue for a future's state, particularly how drop flags and field offsets are assigned for fields holding guards across an .await. The fault is in Arc::drop at arc.rs:287 with a null pointer, so confirm why an Arc field is considered initialized when the future is dropped before it was written. There is no standalone reproduction yet: ask the reporter for relax inspect or flight-recorder output and try to reduce the tokio timeout + guard-across-await shape. Done means a reduced reproducer and drop glue that skips uninitialized fields.

Written by the indexing model from the issue text.

Description

On Relax 953d174a (macOS arm64), dropping an async future segfaults. The same test passes under rustc 1.100.

Observed

A private application's async integration test (tokio multi-thread; a tokio::time::timeout around an async method) segfaults deterministically about 4.8 s in; rustc runs the same test in 0.06 s.

Sanitized top frames:

glue0<Arc<T>>          std/core/sync/arc.rs:287:28   (O2 warm-cache, v1 of 1)
  glue0<closure#...>                                 (drop glue of the async fn's state)
  {closure}@<app>                                    (polls the tokio::time::timeout future)

The fault address is 0xfffffffffffffff0 (a second run: 0xfffffffffffffff2). Arc::drop at arc.rs:287 computes header_of(self.ptr); a null self.ptr yields exactly -size_of::<ArcInner>(), so the Arc field being dropped was zeroed rather than dangling.

Shape

The async fn holds a temporary guard across an .await; the guard owns an Arc:

let v = self.acquire()?.wait().await;

acquire() returns Result<Guard> (the guard owns an Arc clone), and the future is driven by tokio::time::timeout and dropped when it fires.

Reproducing

I have not reduced it to a standalone program yet. Simple async + Arc + timeout shapes do not reproduce:

  • guard temporary across .await, cancelled while pending;
  • the same, completing within the timeout;
  • Arc local across .await, cancelled and completed;
  • yield_now and short sleep variants.

The application is private, so I cannot attach it. I can run diagnostics (relax inspect, flight recorder) or try candidate fixes on request.

Suspect

Looks like async state lowering's drop flag / field offset: the drop glue runs on an Arc field that was never initialized (null, not dangling).

Dominant language
Rust
Stars
601
Forks
34
Avg merge
1h 58m
Merged PRs (30d)
45

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from makepad/relax

All issues in makepad/relax

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.