简体   繁体   English

如何解决 Alpine WSL 中多线程 Rust 应用程序中的分段错误?

[英]How to resolve a Segmentation Fault in a multithreaded Rust application in Alpine WSL?

If I run cargo install-update --list I get a Segmentation fault .如果我运行cargo install-update --list我会收到Segmentation fault

I've noticed the same if I run my CLI applications which use tokio runtime and have.network requests with reqwest .如果我运行使用 tokio runtime 并使用reqwest发出网络请求的 CLI 应用程序,我会注意到同样的情况。 If I run cargo install <package> that works fine.如果我运行cargo install <package>效果很好。 Meaning CLI applications can access the.network.这意味着 CLI 应用程序可以访问 .network。

This is happening in Alpine Linux install in WSL 2 on Windows.这发生在 Alpine Linux 安装在 Windows 的 WSL 2 中。

dmesg shows dmesg 显示

[54391.796247] cargo-install-u[11344]: segfault at 0 ip 0000000000000000 sp 00007ffdf8e9c398 error 14
[54391.797248] Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
[54391.797847] potentially unexpected fatal signal 11.
[54391.798251] CPU: 7 PID: 11344 Comm: cargo-install-u Not tainted 5.15.79.1-microsoft-standard-WSL2 #1
[54391.798906] RIP: 0033:0x0
[54391.799192] Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
[54391.799659] RSP: 002b:00007ffdf8e9c398 EFLAGS: 00010246
[54391.799957] RAX: 00007f40fe395b20 RBX: 00007f40fe3bf480 RCX: 00007ffdf8e9c458
[54391.800407] RDX: 00007ffdf8e9c460 RSI: 0000000000000000 RDI: 0000000000280000

Any hints would be appreciated.任何提示将不胜感激。 I am not sure how to troubleshoot and where to address the problem - whether it is WSL, Alpine Linux, Rust, Tokio, reqwest or somewhere else.我不确定如何排除故障以及在哪里解决问题 - 无论是 WSL、Alpine Linux、Rust、Tokio、reqwest 还是其他地方。

Cargo version: cargo 1.66.0 (d65d197ad 2022-11-15) Cargo 版本: cargo 1.66.0 (d65d197ad 2022-11-15)

Cargo-Update version: cargo-update v11.0.0 Cargo-Update 版本: cargo-update v11.0.0

The related question (thanks, SO.) provides a useful hint about the OpenSSL dependency on Linux systems. 相关问题(谢谢,SO。)提供了有关 OpenSSL 对 Linux 系统的依赖性的有用提示。

Indeed, following the answer there and using rusttls确实,按照那里的答案并使用rusttls

reqwest = { version = "0.11.13", default-features = false, features = ["json", "rustls-tls"] }

instead of the default native-tls, fixes the issue.而不是默认的 native-tls,解决了这个问题。

The reqwest docs list OpenSSL (1.1) as a requirement on Linux. Alpine contains v3 packages with 1.1 compatibility packages but I'm not sure which ones should be installed or if they are by default. reqwest 文档将 OpenSSL (1.1) 列为对 Linux 的要求。Alpine 包含带有 1.1 兼容包的 v3 包,但我不确定应该安装哪些,或者它们是否默认安装。

So, hopefully there would be an option to install whatever necessary package and not to have to change the app dependencies.因此,希望有一个选项可以安装任何必要的 package 而不必更改应用程序依赖项。

In this case I could fix my app that had the Segfault but that won't work for others, like cargo-update for example.在这种情况下,我可以修复我的有段错误但不适用于其他应用程序的应用程序,例如cargo-update

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM