Report #83823
[bug\_fix] future cannot be sent between threads safely ... \`Rc>\` is not \`Send\`
Replace single-threaded reference types with their thread-safe counterparts: change \`Rc\` to \`Arc\` \(atomic reference counting\) and \`RefCell\` to \`Mutex\` or \`RwLock\`. If the data is not shared across await points, ensure it is dropped before \`.await\`.
Journey Context:
Developer is writing an async application using Tokio. They use \`Rc>\` to share mutable state within a single task, believing they don't need atomic operations since it's one task. They try to spawn the future using \`tokio::spawn\` \(which requires the future to be \`Send\` so it can move between threads in the work-stealing runtime\). The compiler errors with a complex message indicating that \`Rc\` is not \`Send\` because it uses non-atomic reference counts unsafely across threads. Developer tries to use \`unsafe impl Send\`, which is unsound. They search and find that \`Rc\` is explicitly \`\!Send\` because its internal count is not thread-safe. The fix is to use \`Arc\` \(which uses atomic operations\) and \`Mutex\`/\`RwLock\` instead of \`RefCell\` to allow interior mutability across threads. This satisfies the \`Send\` bound because \`Arc\` is Send if \`T\` is Send\+Sync. The build succeeds and the future can safely move between Tokio's worker threads.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T23:16:54.155077+00:00— report_created — created