Fight Fire With Fire: How Much Can We Trust ChatGPT on Source Code-Related Tasks?

计算机科学 源代码 编码(集合论) 计算机安全 开源 程序设计语言 软件 集合(抽象数据类型)
作者
Xiao Yu,Lei Liu,Xing Hu,Jacky Keung,Jin Liu,Xin Xia
出处
期刊:IEEE Transactions on Software Engineering [IEEE Computer Society]
卷期号:50 (12): 3435-3453 被引量:61
标识
DOI:10.1109/tse.2024.3492204
摘要

With the increasing utilization of large language models such as ChatGPT during software development, it has become crucial to verify the quality of code content it generates. Recent studies proposed utilizing ChatGPT as both a developer and tester for multi-agent collaborative software development. The multi-agent collaboration empowers ChatGPT to produce test reports for its generated code, enabling it to self-verify the code content and fix bugs based on these reports. However, these studies did not assess the effectiveness of the generated test reports in validating the code. Therefore, we conduct a comprehensive empirical investigation to evaluate ChatGPT's self-verification capability in code generation, code completion, and program repair. We request ChatGPT to (1) generate correct code and then self-verify its correctness; (2) complete code without vulnerabilities and then self-verify for the presence of vulnerabilities; and (3) repair buggy code and then self-verify whether the bugs are resolved. Our findings on two code generation datasets, one code completion dataset, and two program repair datasets reveal the following observations: (1) ChatGPT often erroneously predicts its generated incorrect code as correct, its vulnerable completed code as non-vulnerable, and its failed program repairs as successful during its self-verification. (2) The self-contradictory hallucinations in ChatGPT's behavior arise: (a) ChatGPT initially generates code that it believes to be correct but later predicts it to be incorrect; (b) ChatGPT initially generates code completions that it deems secure but later predicts them to be vulnerable; (c) ChatGPT initially outputs code that it considers successfully repaired but later predicts it to be buggy during its self-verification. (3) The self-verification capability of ChatGPT can be enhanced by asking the guiding question, which queries whether ChatGPT agrees with assertions about incorrectly generated or repaired code and vulnerabilities in completed code. (4) Using test reports generated by ChatGPT can identify more vulnerabilities in completed code, but the explanations for incorrectly generated code and failed repairs are mostly inaccurate in the test reports. Based on these findings, we provide implications for further research or development using ChatGPT.

科研通智能强力驱动
Strongly Powered by AbleSci AI
科研通是完全免费的文献互助平台,具备全网最快的应助速度,最高的求助完成率。 对每一个文献求助,科研通都将尽心尽力,给求助人一个满意的交代。
实时播报
ezekiet发布了新的文献求助10
刚刚
sep完成签到 ,获得积分10
刚刚
酷波er的应助被YYT采纳,获得10
刚刚
gww完成签到,获得积分20
刚刚
1秒前
1秒前
3秒前
斯文败类的应助被科研通管家采纳,获得30
3秒前
3秒前
zxp的应助被科研通管家采纳,获得30
4秒前
十二完成签到 ,获得积分10
4秒前
赘婿的应助被科研通管家采纳,获得10
4秒前
充电宝的应助被科研通管家采纳,获得10
4秒前
bkagyin的应助被科研通管家采纳,获得10
4秒前
4秒前
Jasper的应助被科研通管家采纳,获得10
4秒前
希望天下0贩的0的应助被Nicu采纳,获得10
4秒前
大模型的应助被科研通管家采纳,获得10
4秒前
香蕉觅云的应助被科研通管家采纳,获得10
5秒前
5秒前
灿灿的应助被科研通管家采纳,获得10
5秒前
顾矜的应助被科研通管家采纳,获得10
5秒前
lx的应助被科研通管家采纳,获得10
5秒前
衷燊的应助被科研通管家采纳,获得10
5秒前
null的应助被科研通管家采纳,获得10
5秒前
Ava的应助被科研通管家采纳,获得10
5秒前
爆米花的应助被科研通管家采纳,获得10
6秒前
Will发布了新的文献求助10
6秒前
liuze发布了新的文献求助30
6秒前
CarryLJR的应助被菜菜最菜采纳,获得10
6秒前
无花果的应助被小羊采纳,获得10
8秒前
9秒前
9秒前
Owen的应助被51515采纳,获得10
9秒前
夏目完成签到 ,获得积分10
9秒前
万能图书馆的应助被晚风采纳,获得10
11秒前
cdercder的应助被顺心秋凌采纳,获得10
12秒前
七七发布了新的文献求助10
12秒前
shuangquan关注了科研通微信公众号
12秒前
内向秋烟完成签到,获得积分10
12秒前
高分求助中
(应助此贴封号)【重要!!请各用户(尤其是新用户)详细阅读】【科研通的精品贴汇总】 10000
拉伸高分子熔体中缠结行为的模拟和小角中子散射研究 1700
Grapes 1000
The World Atlas of Wine 9th edition 1000
奈特基础组织学:配套组织病理学(第4版)(Netter's Essential Histology With Correlated Histopathology) 800
John McDowells Bildungstheorie 800
八旗制度の研究 600
热门求助领域 (近24小时)
化学 材料科学 医学 生物 纳米技术 计算机科学 工程类 有机化学 化学工程 生物化学 物理 复合材料 内科学 催化作用 光电子学 人工智能 细胞生物学 无机化学 物理化学 数学
热门帖子
关注 科研通微信公众号,转发送积分 8178807
求助须知:如何正确求助?哪些是违规求助? 9569558
关于积分的说明 21805222
捐赠科研通 7773974
什么是DOI,文献DOI怎么找? 3432933
关于科研通互助平台的介绍 2556873
邀请新用户注册赠送积分活动 2478593