-
Notifications
You must be signed in to change notification settings - Fork 409
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
Segmentation Fault when checking for update #997
Comments
Steps to Reproduce
There is a chance that the segfault won't be triggered on the first run. Use a loop to called it repeatedly. You can also silence stdout to wait for the segfault.
|
Confirmed to not just be a quirk of my computer?
|
I could not make valgrind pick up the segfault so I used the core dump + gdb post-mortem strategy and came up with this backtrace.
This is only one thread, the full thread backtrace is much longer. |
That narrows it down the the call to curl from Lines 242 to 261 in d46d1c6
|
This could be related to curl/curl#6898 since the segfault happens after the help message is printed (and presumably after the request happens) as curl is being cleaned up. |
Is this really doing SFTP over an HTTPS proxy with curl? If not, then it's not that issue. |
Yeah when I actually read the issue in detail it seems less likely to be to same problem. It was just the first issue that mentioned a segmentation fault and it had been posted recently, so I linked it—an imprudent decision, obviously 😅. |
The last entry in the backtrace leads to the construction of an Line 245 in d46d1c6
I made another backtrace to investigate further (gave up on redaction lol. No use anyway.)
After that, it continued down the same path from my other comment. Continuing up the backtrace lead me into the static CURLcode global_init(long flags, bool memoryfuncs)
{
// body elided
}
// doc comment elided
CURLcode curl_global_init(long flags)
{
return global_init(flags, TRUE);
} Reading the body of I'm wary of linking issues after the last time, but I found curl/curl#3990 which mentioned the non-thread-safe nature of |
Going further up the trace leads us to const struct Curl_ssl Curl_ssl_openssl = {
{ CURLSSLBACKEND_OPENSSL, "openssl" }, The function we were looking for, Cloning |
On a separate note, I see absolutely no reason for this tool to use curl at all. Considering this is the only use of curl in the codebase (excluding tests), I find it much simpler to use a pure-rust library for lower overhead and more safety. For example, using fn check_wasm_pack_latest_version() -> Result<Crate, Error> {
let url = "https://crates.io/api/v1/crates/wasm-pack";
let agent = ureq::builder()
.user_agent(&format!(
"wasm-pack/{} ({})",
WASM_PACK_VERSION.unwrap_or("unknown"),
WASM_PACK_REPO_URL
))
.build();
let res = agent.get(url).call().map_err(|err| match err {
Status(status_code, _response) => format_err!(
"Received a bad HTTP status code ({}) when checking for newer wasm-pack version at: {}",
status_code,
url
),
Transport(transport) => transport.into(),
})?;
Ok(res.into_json()?)
} The resulting code, although not as pretty as I could have made it, is simpler and more idiomatic (especially the error handling). If I were to not try to adhere to the previous behavior, the whole mess at the end could be removed, and it starts looking way more like rust code. fn check_wasm_pack_latest_version() -> Result<Crate, Error> {
let url = "https://crates.io/api/v1/crates/wasm-pack";
let agent = ureq::builder()
.user_agent(&format!(
"wasm-pack/{} ({})",
WASM_PACK_VERSION.unwrap_or("unknown"),
WASM_PACK_REPO_URL
))
.build();
Ok(agent.get(url).call()?.into_json()?)
} Most importantly this code does not exhibit the segfault caused by the libcurl version.
I've made these changes in Spaceface16518@4b7411c, if you want me to open a PR. |
I recently encountered this very same issue on the docker image apt-get install libssl-dev
cargo install wasm-pack --no-default-features |
… commit wasm to git repo, yuk
🐛 Bug description
Nothing actually bad happens, but when I try to run
wasm-pack --help
, the help message is printed, followed bySegmentation fault (core dumped)
.🤔 Expected Behavior
Help message should print, and program should exit.
👟 Steps to reproduce
I'm going to try to reproduce it by building it from source and running with valgrind. I will update this section once I have that information.
I'm not doing anything special besides running
wasm-pack help
orwasm-pack --help
. The segfault is not deterministic, but it seems like it happens more often than not (might be confirmation bias though). I will try to get stats on this.UPDATE: posted below
🌍 Your environment
Include the relevant details of your environment.
wasm-pack version:
wasm-pack 0.9.1
rustc version:
rustc 1.51.0 (2fd73fabe 2021-03-23)
The text was updated successfully, but these errors were encountered: