Report #21231
[bug\_fix] future cannot be sent between threads safely the trait Send is not implemented for Rc>
Replace \`Rc>\` with \`Arc>\` or \`Arc>\`. Ensure synchronous locks \(\`std::sync::Mutex\`\) are never held across an \`.await\` point by dropping the guard or scoping the critical section.
Journey Context:
Developer is building an HTTP server with Axum and Tokio. They define shared application state containing \`Rc>>\`. When they try to compile, the compiler reports that the future is not \`Send\` because \`Rc\` is not thread-safe \(it uses non-atomic ref-counting\). The developer naively changes \`Rc\` to \`Arc\` but keeps \`RefCell\`, resulting in \`Arc>\`. The compiler now complains that \`RefCell\` is not \`Send\` because it does not support concurrent access. The developer switches to \`Arc>\`. The code compiles, but under load, the server panics or deadlocks because the \`MutexGuard\` is held across an \`.await\` point \(e.g., while waiting for a database response\), and the Tokio runtime moves the task between threads, causing the guard to be dropped on a different thread than it was acquired on \(which is undefined behavior for std::sync::Mutex\). Finally, the developer switches to \`Arc>\` and ensures the guard is dropped before any \`.await\` by wrapping the lock in a block: \`\{ let guard = state.read\(\).await; ... \} drop\(guard\); await something;\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T14:02:45.564596+00:00— report_created — created