GO RACE 测试在低版本GCC上报错误 exit status 0xc0000139

windows机器环境,go程序使用race定位时一运行就报错,写了个example如:

能看到加了race之后就不行了,

搜了一下,git上有个issue: runtime: Race detector causes exit status 0xc0000139 on Windows 11 with 1.21rc2 running gcc 9.2.0 · Issue #61058 · golang/go · GitHub

里面有个大哥说了一句:

复制代码
Given that the binary works with a newer GCC, this sounds like a GCC bug rather than a Go bug.

然后查了一下,当前的GCC版本是8,

更新了一下,然后就好用了:

这里需要注意的是GCC的更新,别用这个 MinGW Installation Manager 这个东西,这玩意最多只能更新到6.几的版本;

也别用 mingw-w64-install.exe,这个最多只能更新到8.1;

直接去git上 mingw-builds-binaries 下载安装包自己装: Releases · niXman/mingw-builds-binaries · GitHub

下载对应的版本解压之后改一下环境变量重启VSCODE就行了

相关推荐
Tony Bai1 分钟前
高并发后端:坚守 Go,还是拥抱 Rust?
开发语言·后端·golang·rust
wjs202422 分钟前
Swift 类型转换
开发语言
一线大码40 分钟前
SpringBoot 3 和 4 的版本新特性和升级要点
java·spring boot·后端
秃了也弱了。44 分钟前
python实现定时任务:schedule库、APScheduler库
开发语言·python
weixin_440730501 小时前
java数组整理笔记
java·开发语言·笔记
weixin_425023001 小时前
Spring Boot 配置文件优先级详解
spring boot·后端·python
weixin_425023001 小时前
Spring Boot 实用核心技巧汇总:日期格式化、线程管控、MCP服务、AOP进阶等
java·spring boot·后端
一线大码1 小时前
Java 8-25 各个版本新特性总结
java·后端
Thera7771 小时前
状态机(State Machine)详解:原理、优缺点与 C++ 实战示例
开发语言·c++
VX:Fegn08952 小时前
计算机毕业设计|基于springboot + vue校园社团管理系统(源码+数据库+文档)
前端·数据库·vue.js·spring boot·后端·课程设计