Preventing Data Races in Async Coroutines
summary
An example shows 10,000 coroutines racing on an ArrayList and producing missing elements (e.g. 9,988) or internal exceptions. Two concrete defenses appear: a compile‑time Android lint stack analysis that flags variable accesses across coroutine boundaries while allowing immutable or mutex‑guarded data, and a runtime instrumenter TSAN (ThreadSanitizer) that runs JVM tests, instruments field reads/writes, and reports racy stacks. TSAN requires multithreaded tests; lint misses suppressed or unanalyzed code, so both tools serve different practical gaps.
AI-written summary · about
chapters (4)
- 0:00Start
- 2:28Basic idea: flag accesses across coroutine boundaries
- 8:55Sample tsan warning for our example
- 10:38Summary
related talks
28mConcurrency for Imposters
42mKotlin Coroutines: An Intro to Practical Use on Android
01h 03mUsing Kotlin Coroutines for Asynchronous and Concurrent Programming
42mUnderstanding Data Races in the Linux Kernel
41mHanding problems, Coroutines & ReactiveX
44mAsync Showdown: Java Virtual Threads vs. Kotlin Coroutines
45mAll the Pitfalls of Coroutines
40mBuilding Asynchronous Mechanisms in Android App, Using Kotlin Coroutines
