arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2508.09875cs.SE
收藏

Go项目中CGO使用的实证研究——分布、目的、模式与关键问题

An Empirical Study of CGO Usage in Go Projects -- Distribution, Purposes, Patterns and Critical Issues

Jinbao Chen, Boyao Ding, Yu Zhang, Qingwei Li, Fugen Tang

AI总结:

对920个开源Go项目的CGO使用进行实证研究,开发CGOAnalyzer工具揭示其分布、目的、模式及19类关键问题,并提出工具链改进方案以提升开发效率与可靠性。

摘要:

多语言软件开发将多种语言集成到单一应用程序中,其中外部函数接口(FFI)实现了无缝交互。尽管FFI提升了效率和可扩展性,但也引入了风险。现有研究主要关注Python和Java等语言的FFI,忽视了Go语言中新兴的FFI即CGO,而CGO带来了独特的风险。为了解决这些问题,我们对920个开源Go项目中的CGO使用情况进行了实证研究。本研究旨在揭示CGO的分布、模式、目的和关键问题,为开发者和Go团队提供见解。我们开发了CGOAnalyzer,这是一种高效识别和量化CGO相关特征的工具。我们的研究结果表明:(1)11.3%的被分析Go项目使用了CGO,且使用集中在部分项目中;(2)CGO服务于4个主要目的,包括系统级交互和性能优化,共观察到15种不同的使用模式;(3)存在19种CGO相关问题,其中包括一个涉及不必要指针检查的关键问题,由于当前Go编译工具链的限制,该问题带来了运行时崩溃的风险;(4)一个临时解决方案减少了不必要的指针检查,缓解了崩溃风险;(5)我们提交了一份改进Go工具链的提案以实现永久修复,该提案已被归入一份已接受的提案中,留待未来解决。我们的发现为开发者和Go团队提供了有价值的见解,在提高开发效率和可靠性的同时,增强了Go工具链的鲁棒性。

英文摘要:

Multilingual software development integrates multiple languages into a single application, with the Foreign Function Interface (FFI) enabling seamless interaction. While FFI boosts efficiency and extensibility, it also introduces risks. Existing studies focus on FFIs in languages like Python and Java, neglecting CGO, the emerging FFI in Go, which poses unique risks. To address these concerns, we conduct an empirical study of CGO usage across 920 open-source Go projects. Our study aims to reveal the distribution, patterns, purposes, and critical issues associated with CGO, offering insights for developers and the Go team. We develop CGOAnalyzer, a tool to efficiently identify and quantify CGO-related features. Our findings reveal that: (1) 11.3% of analyzed Go projects utilize CGO, with usage concentrated in a subset of projects; (2) CGO serves 4 primary purposes, including system-level interactions and performance optimizations, with 15 distinct usage patterns observed; (3) 19 types of CGO-related issues exist, including one critical issue involving unnecessary pointer checks that pose risks of runtime crashes due to limitations in the current Go compilation toolchain; (4) a temporary solution reduces unnecessary pointer checks, mitigating crash risks, and (5) we submitted a proposal to improve the Go toolchain for a permanent fix, which has been grouped within an accepted proposal for future resolution. Our findings provide valuable insights for developers and the Go team, enhancing development efficiency and reliability while improving the robustness of the Go toolchain.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑