Skip to main content
QUICK REVIEW

[论文解读] Automated Dynamic Concurrency Analysis for Go

Saeed Taheri, Ganesh Gopalakrishnan|arXiv (Cornell University)|May 24, 2021
Artificial Intelligence in GamesComputer Science参考文献 25被引用 1
一句话总结

本文提出了一种用于 Go 的自动化动态并发分析框架,通过在语言内置追踪器中增强并发原语事件,生成详细的执行并发轨迹(ECTs)。通过将这些轨迹存储在结构化的 SQL 数据库中,该方法支持事后分析,识别调度器扰动的关键执行点,并加速并发错误的检测——在 GoKer 基准测试中得到有效验证,可扩展至 2,000 个 goroutine。

ABSTRACT

Kotlin language has recently become prominent for developing both Android and server-side applications. These programs are typically designed to be fast and responsive, with asynchrony and concurrency at their core. To enable developers to write asynchronous and concurrent code safely and concisely, Kotlin provides built-in coroutines support. However, developers unfamiliar with the coroutines concept may write programs with subtle concurrency bugs and face unexpected program behaviors. Besides the traditional concurrency bug patterns, such as data races and deadlocks, these bugs may exhibit patterns related to the coroutine semantics. Understanding these coroutine-specific bug patterns in real-world Kotlin applications is essential in avoiding common mistakes and writing correct programs. In this paper, we present the first study of real-world concurrency bugs related to Kotlin coroutines. We examined 55 concurrency bug cases selected from 7 popular open-source repositories that use Kotlin coroutines, including IntelliJ IDEA, Firefox, and Ktor, and analyzed their bug characteristics and root causes. We identified common bug patterns related to asynchrony and Kotlin’s coroutine semantics, presenting them with their root causes, misconceptions that led to the bugs, and strategies for their automated detection. Overall, this study provides insight into programming with Kotlin coroutines concurrency and its pitfalls, aiming to shed light on common bug patterns and foster further research and development of concurrency analysis tools for Kotlin programs.

研究动机与目标

  • 为解决 Go 复杂并发模型中缺乏有效动态调试支持的问题,特别是难以检测的并发错误。
  • 克服现有工具在大规模 Go 程序中无法处理动态 goroutine 和 channel 创建的局限性。
  • 开发一种自动化、低开销的追踪机制,捕获全面的并发行为,以支持事后分析。
  • 识别调度器扰动能最大程度暴露错误交错执行的关键程序点。
  • 通过利用 ECT 指导有针对性的调度器操作,实现系统化、覆盖驱动的测试。

提出的方法

  • 扩展 Go 内置追踪器,捕获并发原语使用事件(如 channel 发送/接收、mutex 加锁/解锁)以及常规执行事件,生成执行并发轨迹(ECTs)。
  • 设计一个框架,自动对 Go 程序进行插桩,执行过程中收集 ECTs,并将它们持久化存储在关系型 SQL 表格中,以支持结构化分析。
  • 从 ECT 中提取并发操作的源代码位置,识别‘关键点’——即上下文切换可能改变程序行为并暴露错误的位置。
  • 实现调度器扰动机制,在关键点周围注入有界、随机的延迟,以探索未测试的交错执行路径并提高调度覆盖度。
  • 利用 ECT 计算并发覆盖度指标,如 sync-pair、blocking-blocked 和 blocked-pair,以量化测试有效性。
  • 将框架集成到测试流水线中,通过操纵调度器重新执行程序,以提高错误暴露率并优化关键点检测。

实验结果

研究问题

  • RQ1如何增强动态追踪机制,以捕获 Go 程序完整的并发语义,包括动态 goroutine 和 channel 的创建?
  • RQ2哪些关键程序位置(关键点)最能通过调度器扰动改变执行交错顺序并暴露隐藏的并发错误?
  • RQ3与现有工具相比,ECT 基于分析在检测原子性违规及其他 Go 特定并发错误方面能提升多少?
  • RQ4ECT 是否能够实现对大规模 Go 应用(最多 2,000 个 goroutine)的可扩展且实用的事后分析?
  • RQ5基于 ECT 指导的调度器扰动能在多大程度上提高覆盖度并加速难以触发的并发错误的暴露?

主要发现

  • 增强的追踪机制成功捕获了 Go 程序中完整的并发行为,包括动态 goroutine 和 channel 的创建,且运行时开销在可接受范围内。
  • 该框架通过存储在 SQL 数据库中的结构化 ECT,实现了对程序动态并发模型的准确重建。
  • ECT 被用于识别关键执行点,调度器扰动在此类位置可改变程序行为并提高触发错误的可能性。
  • 该方法通过 ECT 分析,在 GoKer 套件的所有阻塞基准测试中均有效检测到错误及其根本原因。
  • 初步结果显示,围绕关键点的调度器扰动显著加速了难以触发的并发错误的暴露,调度覆盖度指标有明显提升。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。