Skip to content
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 downloading via sftp after Pkg.update() #202

Open
baumgold opened this issue Jul 30, 2022 · 4 comments
Open

Segmentation fault downloading via sftp after Pkg.update() #202

baumgold opened this issue Jul 30, 2022 · 4 comments

Comments

@baumgold
Copy link

baumgold commented Jul 30, 2022

When downloading a file via sftp, the Multi finalizer seems to cause a Segmentation fault when calling curl_multi_cleanup here if (and only if) I run Pkg.update() prior to calling Downloads.download (note there is no seg-fault if I comment-out Pkg.update()). Steps to reproduce in Julia v1.7.3:

julia> using Pkg, Downloads

julia> Pkg.update()
    Updating registry at `~/.julia/registries/General.toml`
  No Changes to `~/.julia/environments/v1.7/Project.toml`
  No Changes to `~/.julia/environments/v1.7/Manifest.toml`

julia> Downloads.Curl.PROTOCOL_STATUS["sftp"] = Downloads.Curl.status_zero_ok # https://github.com/JuliaLang/Downloads.jl/pull/180
status_zero_ok (generic function with 1 method)

julia> ENV["JULIA_SSH_NO_VERIFY_HOSTS"] = "sftpng.cmegroup.com"
"sftpng.cmegroup.com"

julia> url = "sftp://<username>:<password>@sftpng.cmegroup.com/path/to/config.xml"
"sftp://<username>:<password>@sftpng.cmegroup.com/path/to/config.xml"

julia> Downloads.download(url)
"/tmp/jl_kxgYuA"

julia> # ^D

signal (11): Segmentation fault
in expression starting at none:0
mbedtls_aesni_crypt_ecb at ~/julia/julia-1.7.3/bin/../lib/julia/libmbedcrypto.so.5 (unknown line)
mbedtls_aes_crypt_ecb at ~/julia/julia-1.7.3/bin/../lib/julia/libmbedcrypto.so.5 (unknown line)
mbedtls_ctr_drbg_random_with_add at ~/julia/julia-1.7.3/bin/../lib/julia/libmbedcrypto.so.5 (unknown line)
mbedtls_ctr_drbg_random at ~/julia/julia-1.7.3/bin/../lib/julia/libmbedcrypto.so.5 (unknown line)
_libssh2_mbedtls_random at ~/julia/julia-1.7.3/bin/../lib/julia/libssh2.so.1 (unknown line)
_libssh2_transport_send at ~/julia/julia-1.7.3/bin/../lib/julia/libssh2.so.1 (unknown line)
_libssh2_channel_close at ~/julia/julia-1.7.3/bin/../lib/julia/libssh2.so.1 (unknown line)
_libssh2_channel_free at ~/julia/julia-1.7.3/bin/../lib/julia/libssh2.so.1 (unknown line)
libssh2_sftp_shutdown at ~/julia/julia-1.7.3/bin/../lib/julia/libssh2.so.1 (unknown line)
ssh_statemach_act at ~/julia/julia-1.7.3/bin/../lib/julia/libcurl.so (unknown line)
ssh_block_statemach.constprop.1 at ~/julia/julia-1.7.3/bin/../lib/julia/libcurl.so (unknown line)
Curl_disconnect at ~/julia/julia-1.7.3/bin/../lib/julia/libcurl.so (unknown line)
Curl_conncache_close_all_connections at ~/julia/julia-1.7.3/bin/../lib/julia/libcurl.so (unknown line)
curl_multi_cleanup at ~/julia/julia-1.7.3/bin/../lib/julia/libcurl.so (unknown line)
curl_multi_cleanup at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/LibCURL/src/lC_curl_h.jl:214 [inlined]
done! at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/Downloads/src/Curl/Multi.jl:28
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
run_finalizer at /buildworker/worker/package_linux64/build/src/gc.c:278
jl_gc_run_finalizers_in_list at /buildworker/worker/package_linux64/build/src/gc.c:365
run_finalizers at /buildworker/worker/package_linux64/build/src/gc.c:394 [inlined]
jl_gc_run_all_finalizers at /buildworker/worker/package_linux64/build/src/gc.c:482
jl_atexit_hook at /buildworker/worker/package_linux64/build/src/init.c:240
jl_repl_entrypoint at /buildworker/worker/package_linux64/build/src/jlapi.c:702
main at julia (unknown line)
__libc_start_main at /lib64/libc.so.6 (unknown line)
unknown function (ip: 0x400808)
Allocations: 5343807 (Pool: 5340217; Big: 3590); GC: 8
Segmentation fault (core dumped)

The sftp site is publicly available (link). If you prefer not to use JULIA_SSH_NO_VERIFY_HOSTS then SSH keys can be installed as follows

ssh-keyscan sftpng.cmegroup.com >> ~/.ssh/known_hosts

More information:

julia> using InteractiveUtils

julia> versioninfo()
Julia Version 1.7.3
Commit 742b9abb4d (2022-05-06 12:58 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) Gold 6136 CPU @ 3.00GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake-avx512)
Environment:
  JULIA_NUM_THREADS = 4
@baumgold baumgold changed the title Segmentation fault with sftp Segmentation fault downloading in a loop Jul 31, 2022
@baumgold baumgold changed the title Segmentation fault downloading in a loop Segmentation fault downloading via sftp in a loop Jul 31, 2022
@baumgold baumgold changed the title Segmentation fault downloading via sftp in a loop Segmentation fault downloading via sftp after Pkg.update() Jul 31, 2022
@baumgold
Copy link
Author

baumgold commented Aug 5, 2022

Is anyone able to help me debug this? I'm not familiar enough with libcurl to quickly pinpoint the problem.

@StefanKarpinski
Copy link
Member

Can you try a newer Julia like 1.8.1?

@StefanKarpinski
Copy link
Member

This works for me on 1.8.1 (with the status_ok patch) and on master it works without the status_ok patch.

@staticfloat
Copy link
Member

@baumgold I noticed that you accidentally exposed your SFTP credentials in your report; I've edited them out, but you should rotate your password to be safe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants