-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
based arch linux dist running ecapture crashed: segmentation violation #604
Comments
你在目标机器上自己编译一次,会有问题吗? |
正常使用 |
OK, 就像#581 里提到的,我需要一个准确的重现办法,你知道这个问题的关键因素吗? |
目前不知道,因为当前分发的文件里没有 debug 符号,看 syscall 也什么都看不出。不过理论上应该开个 arch 容器或者 vm 就能有一样的复现环境了 |
在类 Arch 发行版上可以复现,容器下运行没有问题 |
因为二进制是动态加载的。。得花点时间排查下了。。 |
下载了 0.7.3、0.7.7、0.8.0、0.8.2、0.8.1 这五个历史版本,发现从 0.8.1 开始使用任何子命令都会崩溃,同时尝试在 fedora 40 编译 a2cb6ef 也会崩溃
如果 go 的编译阶段在 arch 上进行则运行正常,如果在 fedora 进行则会崩溃 |
近期我抽空测试一下。 总是卡在vm安装arch系统这里,很繁琐。 |
不用特地安装 arch,相似的测试环境选 manjaro 即可。如果必须必须选 arch,启动 archiso 就是一个干净的测试环境 |
目前看起来是因为提前预编译的二进制文件,在 cast 地址的时候因为不对齐出现了 segement fault 我的建议是这个问题不太好解决,因为需要要求客户锁依赖。最好的方式是通过容器运行,保证二进制的一致性 |
但是只有从 0.8.1 开始才会出问题,会是哪个 commit 引入的问题呢? |
哦?那我来 bisect 一下 |
我还没有重现,我的猜测应该是启用CGO引入libpcap类库后,编译环境的C类库跟运行的环境有差异。 编译构建的环境,期望是可以兼容更多内核的。 如果问题是这里的话,那确实不太好解决。 |
说到这个,我编译时注意到 glibc 提示 libpcap 使用的一些与解析相关的函数仍然需要动态链接 glibc
https://stackoverflow.com/questions/57476533/why-is-statically-linking-glibc-discouraged |
Bisect 下来是 938fcff 这个 commit 引入的破坏 11a498a 这个则没问题 @xxxxxliil 可以确认下 |
938fcff#diff-eb154bbd601602eeae895e7af6a12b88cbdb7d585a2d32216c398f68cabcdff5R188-R197 目前二分代码测出来是和 HTTPServer 有关,我猜是两个 goroutine 同时初始化 CGO 然后 G 了,我看来看下汇编看看 |
查出来问题了。。和 glibc 版本有关 在 #541 中我们引入了 Gin 来作为 HTTP Server 支持 Conf 通过 HTTP 变更。938fcff#diff-eb154bbd601602eeae895e7af6a12b88cbdb7d585a2d32216c398f68cabcdff5R189-R196 而我们默认给的地址是 而目前 Ubuntu 常见的 glibc 版本是 2.35 而 Arch Linux 是 2.40 ,结构有所变化,导致编译产物会 SIGSEGV 目前看下来最好的解决方案是我们彻底不支持域名 address 的绑定,我觉得这样也能接受?@cfc4n BTW Go 的 Resolver 是老问题了,FYI golang/go#30310 |
以及构建时使用 @cfc4n on your call(XD |
确实,这个结论比较合理,能很好地解释了报错堆栈里的 至于修复方式,我觉得是可以启用 另外,报错信息中还有一个关键信息 |
还有,在编译时,能够看到 我需要仔细斟酌一下。 /usr/bin/ld: /ecapture/lib/libpcap//libpcap.a(nametoaddr.o): in function `pcap_nametoaddrinfo':
/ecapture/lib/libpcap/./nametoaddr.c:207: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /ecapture/lib/libpcap//libpcap.a(nametoaddr.o): in function `pcap_nametoaddr':
/ecapture/lib/libpcap/./nametoaddr.c:181: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /ecapture/lib/libpcap//libpcap.a(nametoaddr.o): in function `pcap_nametonetaddr':
/ecapture/lib/libpcap/./nametoaddr.c:270: warning: Using 'getnetbyname_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /ecapture/lib/libpcap//libpcap.a(nametoaddr.o): in function `pcap_nametoproto':
/ecapture/lib/libpcap/./nametoaddr.c:527: warning: Using 'getprotobyname_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking |
是的, 这是一个隐藏但是没炸的雷,我的建议是我们彻底放弃二进制的分发,统一交给容器处理 |
不要禁用localhost的支持,禁用后,无法用一套配置同时运行在纯v4和纯v6的环境了,必须区分出 |
确实,所以还是老老实实 netgo 吧 |
我们可以尝试使用 musl 作为静态链接时的 libc 吗? |
底层类库变更,稳定性风险更大,暂时不考虑。 |
MUSL 就算了。。。坑一抹多。。。 |
#581 使用 0.8.6 之后已解决问题 |
Describe the bug
最近的两个版本,0.8.4 和 0.8.5 在 arch 中运行都会出现一样的
SIGSEGV: segmentation violation
不一定总是在 Module.run() 出现问题,在
https server starting...You can update the configuration file via the HTTP interface.
与BPF bytecode file is matched. bpfFileName=user/bytecode/openssl_3_0_0_kern_core.o
但是最常出现的就是前两个输出后立刻 segmentation violation
To Reproduce
Steps to reproduce the behavior:
# ./ecapture [any command]
Expected behavior
正常捕获内容
Screenshots
https://fars.ee/b9La
V.log
https://fars.ee/gU9L
V2.log
https://fars.ee/_SWJ
v3.log
V3.log
Linux Server/Android (please complete the following information):
Additional context
在 #581 提及过一次
The text was updated successfully, but these errors were encountered: