rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.81k stars 2.43k forks source link

cargo build crash: double free or corruption (!prev): 0x00007fb9ac2c1880 *** #10034

Closed iiibui closed 2 years ago

iiibui commented 3 years ago

Problem

cargo crash when I change registry in ~/.cargo/config

OS: CentOS Linux release 7.3.1611 (Core)

By the way my machine use proxy to connect Internet.

*** Error in `/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo': double free or corruption (!prev): 0x00007fb9ac2c1880 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x7c503)[0x7fb9a94a5503]
/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo(+0x8cd806)[0x7fb9aae19806]
/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo(+0x8cd69e)[0x7fb9aae1969e]
/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo(+0x8e22f7)[0x7fb9aae2e2f7]
/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo(+0x8bef04)[0x7fb9aae0af04]
/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo(_ZN5cargo3ops7resolve20resolve_ws_with_opts17h01d5332c4f804ec9E+0x666)[0x7fb9aaaba306]
/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo(_ZN5cargo3ops13cargo_compile10create_bcx17h79470c5de3e513acE+0x393)[0x7fb9aa9fe093]
/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo(_ZN5cargo3ops13cargo_compile10compile_ws17hc05b461b8c8955ecE+0x8e)[0x7fb9aa9fd2ce]
/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo(_ZN5cargo3ops13cargo_compile7compile17ha79b172fff332ebeE+0x96)[0x7fb9aa9fd206]
/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo(+0x1ed7a1)[0x7fb9aa7397a1]
/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo(+0x1c60a0)[0x7fb9aa7120a0]
/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo(+0x1eede5)[0x7fb9aa73ade5]
/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo(+0x1b7203)[0x7fb9aa703203]
/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo(+0x1e7569)[0x7fb9aa733569]
/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo(_ZN3std2rt19lang_start_internal17hdd488b91dc742b96E+0x30a)[0x7fb9ab0447fa]
/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo(+0x1f0fd2)[0x7fb9aa73cfd2]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7fb9a944ab35]
/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo(+0x178f01)[0x7fb9aa6c4f01]
======= Memory map: ========
7fb9a4000000-7fb9a4021000 rw-p 00000000 00:00 0
7fb9a4021000-7fb9a8000000 ---p 00000000 00:00 0
7fb9a9429000-7fb9a95df000 r-xp 00000000 fd:01 25202154                   /usr/lib64/libc-2.17.so
7fb9a95df000-7fb9a97df000 ---p 001b6000 fd:01 25202154                   /usr/lib64/libc-2.17.so
7fb9a97df000-7fb9a97e3000 r--p 001b6000 fd:01 25202154                   /usr/lib64/libc-2.17.so
7fb9a97e3000-7fb9a97e5000 rw-p 001ba000 fd:01 25202154                   /usr/lib64/libc-2.17.so
7fb9a97e5000-7fb9a97ea000 rw-p 00000000 00:00 0
7fb9a97ea000-7fb9a97ec000 r-xp 00000000 fd:01 25202160                   /usr/lib64/libdl-2.17.so
7fb9a97ec000-7fb9a99ec000 ---p 00002000 fd:01 25202160                   /usr/lib64/libdl-2.17.so
7fb9a99ec000-7fb9a99ed000 r--p 00002000 fd:01 25202160                   /usr/lib64/libdl-2.17.so
7fb9a99ed000-7fb9a99ee000 rw-p 00003000 fd:01 25202160                   /usr/lib64/libdl-2.17.so
7fb9a99ee000-7fb9a9aee000 r-xp 00000000 fd:01 25202162                   /usr/lib64/libm-2.17.so
7fb9a9aee000-7fb9a9cee000 ---p 00100000 fd:01 25202162                   /usr/lib64/libm-2.17.so
7fb9a9cee000-7fb9a9cef000 r--p 00100000 fd:01 25202162                   /usr/lib64/libm-2.17.so
7fb9a9cef000-7fb9a9cf0000 rw-p 00101000 fd:01 25202162                   /usr/lib64/libm-2.17.so
7fb9a9cf0000-7fb9a9d07000 r-xp 00000000 fd:01 25202181                   /usr/lib64/libpthread-2.17.so
7fb9a9d07000-7fb9a9f06000 ---p 00017000 fd:01 25202181                   /usr/lib64/libpthread-2.17.so
7fb9a9f06000-7fb9a9f07000 r--p 00016000 fd:01 25202181                   /usr/lib64/libpthread-2.17.so
7fb9a9f07000-7fb9a9f08000 rw-p 00017000 fd:01 25202181                   /usr/lib64/libpthread-2.17.so
7fb9a9f08000-7fb9a9f0c000 rw-p 00000000 00:00 0
7fb9a9f0c000-7fb9a9f13000 r-xp 00000000 fd:01 25202185                   /usr/lib64/librt-2.17.so
7fb9a9f13000-7fb9aa112000 ---p 00007000 fd:01 25202185                   /usr/lib64/librt-2.17.so
7fb9aa112000-7fb9aa113000 r--p 00006000 fd:01 25202185                   /usr/lib64/librt-2.17.so
7fb9aa113000-7fb9aa114000 rw-p 00007000 fd:01 25202185                   /usr/lib64/librt-2.17.so
7fb9aa114000-7fb9aa129000 r-xp 00000000 fd:01 25301469                   /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7fb9aa129000-7fb9aa328000 ---p 00015000 fd:01 25301469                   /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7fb9aa328000-7fb9aa329000 r--p 00014000 fd:01 25301469                   /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7fb9aa329000-7fb9aa32a000 rw-p 00015000 fd:01 25301469                   /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7fb9aa32a000-7fb9aa34a000 r-xp 00000000 fd:01 25202147                   /usr/lib64/ld-2.17.so
7fb9aa537000-7fb9aa53c000 rw-p 00000000 00:00 0
7fb9aa543000-7fb9aa544000 rw-p 00000000 00:00 0
7fb9aa544000-7fb9aa545000 r--s 00000000 00:04 458753                     /SYSV00000072 (deleted)
7fb9aa545000-7fb9aa546000 ---p 00000000 00:00 0
7fb9aa546000-7fb9aa549000 rw-p 00000000 00:00 0
7fb9aa549000-7fb9aa54a000 r--p 0001f000 fd:01 25202147                   /usr/lib64/ld-2.17.so
7fb9aa54a000-7fb9aa54b000 rw-p 00020000 fd:01 25202147                   /usr/lib64/ld-2.17.so
7fb9aa54b000-7fb9aa54c000 rw-p 00000000 00:00 0
7fb9aa54c000-7fb9ab367000 r-xp 00000000 fd:01 142727009                  /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo
7fb9ab566000-7fb9ab60c000 r--p 00e1a000 fd:01 142727009                  /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo
7fb9ab60c000-7fb9ab614000 rw-p 00ec0000 fd:01 142727009                  /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo
7fb9ab614000-7fb9ab619000 rw-p 00000000 00:00 0
7fb9ac1bc000-7fb9ac46b000 rw-p 00000000 00:00 0                          [heap]
7ffc7e06f000-7ffc7e090000 rw-p 00000000 00:00 0                          [stack]
7ffc7e0a1000-7ffc7e0a3000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Aborted

Steps

  1. Install rust toolchain by rustup-init.sh
  2. Change ~/.cargo/config to:
    [source.crates-io]
    registry = "https://github.com/rust-lang/crates.io-index"
    replace-with = 'ustc'
    [source.ustc]
    registry = "https://mirrors.ustc.edu.cn/crates.io-index/"
  3. Create a new project by cargo new
  4. Add some dependencies in the new project Cargo.toml file:
    
    [package]
    name = "hello"
    version = "0.1.0"
    edition = "2021"

See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies] serde = { version = "1.0.118" }

5. Run cargo build in the new project path then cargo crash after Updating index and Downloading message
6. Comment out "replace-with = 'ustc'" in ~/.cargo/config then retry cargo build, it has no preblem

### Possible Solution(s)

_No response_

### Notes

Using the same ~/.cargo/config in my other machine which use different networks is OK.

### Version

```text
cargo 1.56.0 (4ed5d137b 2021-10-04)
release: 1.56.0
commit-hash: 4ed5d137baff5eccf1bae5a7b2ae4b57efad4a7d
commit-date: 2021-10-04
ehuss commented 3 years ago

Can you say more on how the proxy is configured? Are you setting the $http_proxy environment variable?

iiibui commented 3 years ago

Can you say more on how the proxy is configured? Are you setting the $http_proxy environment variable?

Yes, the $http_proxy environment variable was set, it point to the localhost and port, but I don't know much about the proxy, it seems to be tinyproxy. I build the cargo myself, which link to libcurl/7.73.0 OpenSSL/1.1.1h zlib/1.2.7 nghttp2/1.41.0, it not crash but say:

error: failed to download from `https://crates-io.proxy.ustclug.org/api/v1/crates/bincode/1.3.3/download`

Caused by:
  [60] SSL peer certificate or SSH remote key was not OK (SSL certificate problem: unable to get local issuer certificate)

I also tried the nightly cargo(94ca096af 2021-10-29), it crash too.

iiibui commented 3 years ago

I update my libcurl then rebuild cargo and try again it crash now:

*** Error in `/home/apps/github/cargo/target/debug/cargo': double free or corruption (!prev): 0x00007f4ed4cc3f10 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x7c503)[0x7f4eceb66503]
/apps/svr/curl/lib/libcurl.so.4(+0x57d08)[0x7f4ed009bd08]
/apps/svr/curl/lib/libcurl.so.4(+0x58c3c)[0x7f4ed009cc3c]
/apps/svr/curl/lib/libcurl.so.4(+0x1132c)[0x7f4ed005532c]
/apps/svr/curl/lib/libcurl.so.4(curl_multi_cleanup+0xbf)[0x7f4ed0081bff]
/home/apps/github/cargo/target/debug/cargo(_ZN63_$LT$curl..multi..RawMulti$u20$as$u20$core..ops..drop..Drop$GT$4drop17h6bde5207d45d1fbbE+0x12)[0x7f4ed2924c22]
/home/apps/github/cargo/target/debug/cargo(_ZN4core3ptr42drop_in_place$LT$curl..multi..RawMulti$GT$17hb80e7051e9188cd8E+0xb)[0x7f4ed29229cb]
/home/apps/github/cargo/target/debug/cargo(_ZN5alloc4sync12Arc$LT$T$GT$9drop_slow17h4056edc78815579aE+0x24)[0x7f4ed2920034]
/home/apps/github/cargo/target/debug/cargo(_ZN67_$LT$alloc..sync..Arc$LT$T$GT$$u20$as$u20$core..ops..drop..Drop$GT$4drop17hf86449b2b8a20dd5E+0x63)[0x7f4ed2920193]
/home/apps/github/cargo/target/debug/cargo(_ZN4core3ptr66drop_in_place$LT$alloc..sync..Arc$LT$curl..multi..RawMulti$GT$$GT$17h488dd6ba84f7af8bE+0xb)[0x7f4ed29232bb]
/home/apps/github/cargo/target/debug/cargo(_ZN4core3ptr39drop_in_place$LT$curl..multi..Multi$GT$17h1a0a9b2b586c92d7E+0x17)[0x7f4ed16ff7f7]
/home/apps/github/cargo/target/debug/cargo(_ZN4core3ptr53drop_in_place$LT$cargo..core..package..PackageSet$GT$17hc7af24d9fe331ef5E+0x6e)[0x7f4ed17046ce]
/home/apps/github/cargo/target/debug/cargo(+0x17c7b23)[0x7f4ed1eceb23]
/home/apps/github/cargo/target/debug/cargo(+0xd2b431)[0x7f4ed1432431]
/home/apps/github/cargo/target/debug/cargo(_ZN5cargo3ops13cargo_compile10compile_ws17h6451470fa10ad87cE+0x83)[0x7f4ed1430cc3]
/home/apps/github/cargo/target/debug/cargo(+0xd29c0f)[0x7f4ed1430c0f]
/home/apps/github/cargo/target/debug/cargo(_ZN5cargo3ops13cargo_compile7compile17ha1b60d59a465df32E+0x5e)[0x7f4ed1430b4e]
/home/apps/github/cargo/target/debug/cargo(+0xc915f0)[0x7f4ed13985f0]
/home/apps/github/cargo/target/debug/cargo(+0xc44214)[0x7f4ed134b214]
/home/apps/github/cargo/target/debug/cargo(+0xc40d24)[0x7f4ed1347d24]
/home/apps/github/cargo/target/debug/cargo(+0xc558cc)[0x7f4ed135c8cc]
/home/apps/github/cargo/target/debug/cargo(+0xccba0b)[0x7f4ed13d2a0b]
/home/apps/github/cargo/target/debug/cargo(+0xcb64ce)[0x7f4ed13bd4ce]
/home/apps/github/cargo/target/debug/cargo(+0xcb2af1)[0x7f4ed13b9af1]
/home/apps/github/cargo/target/debug/cargo(_ZN3std2rt19lang_start_internal17h571831ebdba142deE+0x431)[0x7f4ed2ac9b61]
/home/apps/github/cargo/target/debug/cargo(+0xcb2ac0)[0x7f4ed13b9ac0]
/home/apps/github/cargo/target/debug/cargo(+0xc57f8c)[0x7f4ed135ef8c]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7f4eceb0bb35]
/home/apps/github/cargo/target/debug/cargo(+0xc38fa9)[0x7f4ed133ffa9]
======= Memory map: ========
7f4ec8000000-7f4ec8021000 rw-p 00000000 00:00 0
7f4ec8021000-7f4ecc000000 ---p 00000000 00:00 0
7f4eccaf9000-7f4eccb37000 r-xp 00000000 fd:21 537384241                  /mnt/vdc1/apps/lib/pcre-8.31/lib/libpcre.so.1.0.1
7f4eccb37000-7f4eccd36000 ---p 0003e000 fd:21 537384241                  /mnt/vdc1/apps/lib/pcre-8.31/lib/libpcre.so.1.0.1
7f4eccd36000-7f4eccd37000 r--p 0003d000 fd:21 537384241                  /mnt/vdc1/apps/lib/pcre-8.31/lib/libpcre.so.1.0.1
7f4eccd37000-7f4eccd38000 rw-p 0003e000 fd:21 537384241                  /mnt/vdc1/apps/lib/pcre-8.31/lib/libpcre.so.1.0.1
7f4eccd38000-7f4eccd5c000 r-xp 00000000 fd:01 25165954                   /usr/lib64/libselinux.so.1
7f4eccd5c000-7f4eccf5b000 ---p 00024000 fd:01 25165954                   /usr/lib64/libselinux.so.1
7f4eccf5b000-7f4eccf5c000 r--p 00023000 fd:01 25165954                   /usr/lib64/libselinux.so.1
7f4eccf5c000-7f4eccf5d000 rw-p 00024000 fd:01 25165954                   /usr/lib64/libselinux.so.1
7f4eccf5d000-7f4eccf5f000 rw-p 00000000 00:00 0
7f4eccf5f000-7f4eccf75000 r-xp 00000000 fd:01 25202183                   /usr/lib64/libresolv-2.17.so
7f4eccf75000-7f4ecd175000 ---p 00016000 fd:01 25202183                   /usr/lib64/libresolv-2.17.so
7f4ecd175000-7f4ecd176000 r--p 00016000 fd:01 25202183                   /usr/lib64/libresolv-2.17.so
7f4ecd176000-7f4ecd177000 rw-p 00017000 fd:01 25202183                   /usr/lib64/libresolv-2.17.so
7f4ecd177000-7f4ecd179000 rw-p 00000000 00:00 0
7f4ecd179000-7f4ecd17c000 r-xp 00000000 fd:01 25301165                   /usr/lib64/libkeyutils.so.1.5
7f4ecd17c000-7f4ecd37b000 ---p 00003000 fd:01 25301165                   /usr/lib64/libkeyutils.so.1.5
7f4ecd37b000-7f4ecd37c000 r--p 00002000 fd:01 25301165                   /usr/lib64/libkeyutils.so.1.5
7f4ecd37c000-7f4ecd37d000 rw-p 00003000 fd:01 25301165                   /usr/lib64/libkeyutils.so.1.5
7f4ecd37d000-7f4ecd38a000 r-xp 00000000 fd:01 25166462                   /usr/lib64/libkrb5support.so.0.1
7f4ecd38a000-7f4ecd58a000 ---p 0000d000 fd:01 25166462                   /usr/lib64/libkrb5support.so.0.1
7f4ecd58a000-7f4ecd58b000 r--p 0000d000 fd:01 25166462                   /usr/lib64/libkrb5support.so.0.1
7f4ecd58b000-7f4ecd58c000 rw-p 0000e000 fd:01 25166462                   /usr/lib64/libkrb5support.so.0.1
7f4ecd58c000-7f4ecd5bb000 r-xp 00000000 fd:01 25166454                   /usr/lib64/libk5crypto.so.3.1
7f4ecd5bb000-7f4ecd7ba000 ---p 0002f000 fd:01 25166454                   /usr/lib64/libk5crypto.so.3.1
7f4ecd7ba000-7f4ecd7bc000 r--p 0002e000 fd:01 25166454                   /usr/lib64/libk5crypto.so.3.1
7f4ecd7bc000-7f4ecd7bd000 rw-p 00030000 fd:01 25166454                   /usr/lib64/libk5crypto.so.3.1
7f4ecd7bd000-7f4ecd7be000 rw-p 00000000 00:00 0
7f4ecd7be000-7f4ecd7c1000 r-xp 00000000 fd:01 25166429                   /usr/lib64/libcom_err.so.2.1
7f4ecd7c1000-7f4ecd9c0000 ---p 00003000 fd:01 25166429                   /usr/lib64/libcom_err.so.2.1
7f4ecd9c0000-7f4ecd9c1000 r--p 00002000 fd:01 25166429                   /usr/lib64/libcom_err.so.2.1
7f4ecd9c1000-7f4ecd9c2000 rw-p 00003000 fd:01 25166429                   /usr/lib64/libcom_err.so.2.1
7f4ecd9c2000-7f4ecda98000 r-xp 00000000 fd:01 25166460                   /usr/lib64/libkrb5.so.3.3
7f4ecda98000-7f4ecdc98000 ---p 000d6000 fd:01 25166460                   /usr/lib64/libkrb5.so.3.3
7f4ecdc98000-7f4ecdca6000 r--p 000d6000 fd:01 25166460                   /usr/lib64/libkrb5.so.3.3
7f4ecdca6000-7f4ecdca9000 rw-p 000e4000 fd:01 25166460                   /usr/lib64/libkrb5.so.3.3
7f4ecdca9000-7f4ecdcf4000 r-xp 00000000 fd:01 25166450                   /usr/lib64/libgssapi_krb5.so.2.2
7f4ecdcf4000-7f4ecdef4000 ---p 0004b000 fd:01 25166450                   /usr/lib64/libgssapi_krb5.so.2.2
7f4ecdef4000-7f4ecdef5000 r--p 0004b000 fd:01 25166450                   /usr/lib64/libgssapi_krb5.so.2.2
7f4ecdef5000-7f4ecdef7000 rw-p 0004c000 fd:01 25166450                   /usr/lib64/libgssapi_krb5.so.2.2
7f4ecdef7000-7f4ece1af000 r-xp 00000000 fd:21 539323071                  /mnt/vdc1/apps/svr/openssl/lib/libcrypto.so.1.1
7f4ece1af000-7f4ece3ae000 ---p 002b8000 fd:21 539323071                  /mnt/vdc1/apps/svr/openssl/lib/libcrypto.so.1.1
7f4ece3ae000-7f4ece3d9000 r--p 002b7000 fd:21 539323071                  /mnt/vdc1/apps/svr/openssl/lib/libcrypto.so.1.1
7f4ece3d9000-7f4ece3dc000 rw-p 002e2000 fd:21 539323071                  /mnt/vdc1/apps/svr/openssl/lib/libcrypto.so.1.1
7f4ece3dc000-7f4ece3e0000 rw-p 00000000 00:00 0
7f4ece3e0000-7f4ece466000 r-xp 00000000 fd:21 539329216                  /mnt/vdc1/apps/svr/openssl/lib/libssl.so.1.1
7f4ece466000-7f4ece665000 ---p 00086000 fd:21 539329216                  /mnt/vdc1/apps/svr/openssl/lib/libssl.so.1.1
7f4ece665000-7f4ece66d000 r--p 00085000 fd:21 539329216                  /mnt/vdc1/apps/svr/openssl/lib/libssl.so.1.1
7f4ece66d000-7f4ece672000 rw-p 0008d000 fd:21 539329216                  /mnt/vdc1/apps/svr/openssl/lib/libssl.so.1.1
7f4ece672000-7f4ece6c0000 r-xp 00000000 fd:01 26614798                   /usr/local/lib/libidn2.so.0.3.7
7f4ece6c0000-7f4ece8c0000 ---p 0004e000 fd:01 26614798                   /usr/local/lib/libidn2.so.0.3.7
7f4ece8c0000-7f4ece8c1000 r--p 0004e000 fd:01 26614798                   /usr/local/lib/libidn2.so.0.3.7
7f4ece8c1000-7f4ece8c2000 rw-p 0004f000 fd:01 26614798                   /usr/local/lib/libidn2.so.0.3.7
7f4ece8c2000-7f4ece8e7000 r-xp 00000000 fd:21 539381085                  /mnt/vdc1/apps/svr/nghttp2/lib/libnghttp2.so.14.20.0
7f4ece8e7000-7f4eceae6000 ---p 00025000 fd:21 539381085                  /mnt/vdc1/apps/svr/nghttp2/lib/libnghttp2.so.14.20.0
7f4eceae6000-7f4eceae9000 r--p 00024000 fd:21 539381085                  /mnt/vdc1/apps/svr/nghttp2/lib/libnghttp2.so.14.20.0
7f4eceae9000-7f4eceaea000 rw-p 00027000 fd:21 539381085                  /mnt/vdc1/apps/svr/nghttp2/lib/libnghttp2.so.14.20.0Aborted
oxalica commented 2 years ago

I've run into this. Is it fixed by recent bumping to curl 0.4.41 in https://github.com/rust-lang/cargo/commit/22ff7ac47c0e3a366637643c9cf38c61d649c10b ?

I'm waiting for a patch release for it.

ehuss commented 2 years ago

Yea, I believe this should be closed by #10106, thanks!