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

Segfault when using async on linux-musl #107566

Closed
WhyNotHugo opened this issue Feb 1, 2023 · 12 comments
Closed

Segfault when using async on linux-musl #107566

WhyNotHugo opened this issue Feb 1, 2023 · 12 comments
Labels
C-bug Category: This is a bug. O-musl Target: The musl libc

Comments

@WhyNotHugo
Copy link

I tried this code:

#[tokio::main]
async fn main() {
    reqwest::get("https://www.rust-lang.org")
        .await
        .unwrap()
        .text()
        .await
        .unwrap();
}

And this Cargo.toml:

[package]
name = "reproducer"
version = "0.1.0"
edition = "2021"

[dependencies]
reqwest = "0.11.14"
tokio = { version = "1.25.0", features = ["rt", "macros", "rt-multi-thread"] }

I expected to see this happen: It would run fine

Instead, this happened: segmentation fault

Meta

rustc --version --verbose:

rustc 1.69.0-nightly (dc1d9d50f 2023-01-31)
binary: rustc
commit-hash: dc1d9d50fba2f6a1ccab8748a0050cde38253f60
commit-date: 2023-01-31
host: x86_64-unknown-linux-musl
release: 1.69.0-nightly
LLVM version: 15.0.7

strace (not sure if useful):

execve("./target/debug/reproducer", ["./target/debug/reproducer"], 0x7ffea4cde630 /* 72 vars */) = 0
mmap(NULL, 592, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9411d5f000
arch_prctl(ARCH_SET_FS, 0x7f9411d5f170) = 0
set_tid_address(0x7f9411cfe3e0)         = 23180
poll([{fd=0, events=0}, {fd=1, events=0}, {fd=2, events=0}], 3, 0) = 0 (Timeout)
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f9411b1b2c3}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGSEGV, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RT_1 RT_2], NULL, 8) = 0
rt_sigaction(SIGSEGV, {sa_handler=0x7f9411af3260, sa_mask=[], sa_flags=SA_RESTORER|SA_ONSTACK|SA_SIGINFO, sa_restorer=0x7f9411b1b2c3}, NULL, 8) = 0
rt_sigaction(SIGBUS, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGBUS, {sa_handler=0x7f9411af3260, sa_mask=[], sa_flags=SA_RESTORER|SA_ONSTACK|SA_SIGINFO, sa_restorer=0x7f9411b1b2c3}, NULL, 8) = 0
sigaltstack(NULL, {ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=0}) = 0
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f9411d5c000
mprotect(0x7f9411d5c000, 4096, PROT_NONE) = 0
sigaltstack({ss_sp=0x7f9411d5d000, ss_flags=0, ss_size=8192}, NULL) = 0
brk(NULL)                               = 0x555555917000
brk(0x555555918000)                     = 0x555555918000
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
getrandom("\x1f\x88\xfa\x21\x75\xdc\x78\x07\x3c\x3e\x82\xc8\x79\x04\xcb\x88", 16, GRND_INSECURE) = 16
open("/proc/self/cgroup", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
brk(0x55555591b000)                     = 0x55555591b000
read(3, "12:pids:/\n11:net_prio:/\n10:perf_"..., 8192) = 149
read(3, "", 8192)                       = 0
close(3)                                = 0
open("/proc/self/mountinfo", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
read(3, "16 23 0:15 / /sys rw,nosuid,node"..., 8192) = 2735
close(3)                                = 0
open("/sys/fs/cgroup/cpu/cpu.cfs_quota_us", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
lseek(3, 0, SEEK_CUR)                   = 0
read(3, "-1\n", 32)                     = 3
read(3, "", 29)                         = 0
close(3)                                = 0
sched_getaffinity(0, 128, [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23]) = 8
epoll_create1(EPOLL_CLOEXEC)            = 3
eventfd2(0, EFD_CLOEXEC|EFD_NONBLOCK)   = 4
epoll_ctl(3, EPOLL_CTL_ADD, 4, {events=EPOLLIN|EPOLLRDHUP|EPOLLET, data={u32=2147483648, u64=2147483648}}) = 0
fcntl(3, F_DUPFD_CLOEXEC, 3)            = 5
fcntl(5, F_SETFD, FD_CLOEXEC)           = 0
brk(0x55555591d000)                     = 0x55555591d000
brk(0x55555591e000)                     = 0x55555591e000
brk(0x55555591f000)                     = 0x55555591f000
brk(0x555555920000)                     = 0x555555920000
brk(0x555555921000)                     = 0x555555921000
brk(0x555555922000)                     = 0x555555922000
brk(0x555555923000)                     = 0x555555923000
brk(0x555555924000)                     = 0x555555924000
brk(0x555555925000)                     = 0x555555925000
brk(0x555555926000)                     = 0x555555926000
brk(0x555555927000)                     = 0x555555927000
brk(0x555555928000)                     = 0x555555928000
brk(0x555555929000)                     = 0x555555929000
brk(0x55555592a000)                     = 0x55555592a000
brk(0x55555592b000)                     = 0x55555592b000
rt_sigprocmask(SIG_UNBLOCK, [RT_1 RT_2], NULL, 8) = 0
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f94113fd000
mprotect(0x7f94113ff000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f94115ff988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23181], tls=0x7f94115ffb20, child_tidptr=0x7f9411cfe3e0) = 23181
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f94111fa000
mprotect(0x7f94111fc000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f94113fc988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23182], tls=0x7f94113fcb20, child_tidptr=0x7f9411cfe3e0) = 23182
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9410ff7000
mprotect(0x7f9410ff9000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f94111f9988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23183], tls=0x7f94111f9b20, child_tidptr=0x7f9411cfe3e0) = 23183
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
brk(0x55555592c000)                     = 0x55555592c000
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9410df4000
mprotect(0x7f9410df6000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f9410ff6988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23184], tls=0x7f9410ff6b20, child_tidptr=0x7f9411cfe3e0) = 23184
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9410bf1000
mprotect(0x7f9410bf3000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f9410df3988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23185], tls=0x7f9410df3b20, child_tidptr=0x7f9411cfe3e0) = 23185
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f94109ee000
mprotect(0x7f94109f0000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f9410bf0988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23186], tls=0x7f9410bf0b20, child_tidptr=0x7f9411cfe3e0) = 23186
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f94107eb000
mprotect(0x7f94107ed000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f94109ed988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23187], tls=0x7f94109edb20, child_tidptr=0x7f9411cfe3e0) = 23187
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f94105e8000
mprotect(0x7f94105ea000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f94107ea988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23188], tls=0x7f94107eab20, child_tidptr=0x7f9411cfe3e0) = 23188
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f94103e5000
mprotect(0x7f94103e7000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f94105e7988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23189], tls=0x7f94105e7b20, child_tidptr=0x7f9411cfe3e0) = 23189
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f94101e2000
mprotect(0x7f94101e4000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f94103e4988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23190], tls=0x7f94103e4b20, child_tidptr=0x7f9411cfe3e0) = 23190
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f940ffdf000
mprotect(0x7f940ffe1000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f94101e1988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23191], tls=0x7f94101e1b20, child_tidptr=0x7f9411cfe3e0) = 23191
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f940fddc000
mprotect(0x7f940fdde000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f940ffde988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23192], tls=0x7f940ffdeb20, child_tidptr=0x7f9411cfe3e0) = 23192
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f940fbd9000
mprotect(0x7f940fbdb000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f940fddb988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23193], tls=0x7f940fddbb20, child_tidptr=0x7f9411cfe3e0) = 23193
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f940f9d6000
mprotect(0x7f940f9d8000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f940fbd8988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23194], tls=0x7f940fbd8b20, child_tidptr=0x7f9411cfe3e0) = 23194
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f940f7d3000
mprotect(0x7f940f7d5000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f940f9d5988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23195], tls=0x7f940f9d5b20, child_tidptr=0x7f9411cfe3e0) = 23195
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
brk(0x55555592e000)                     = 0x55555592e000
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f940f5d0000
mprotect(0x7f940f5d2000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f940f7d2988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23196], tls=0x7f940f7d2b20, child_tidptr=0x7f9411cfe3e0) = 23196
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f940f3cd000
mprotect(0x7f940f3cf000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f940f5cf988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23197], tls=0x7f940f5cfb20, child_tidptr=0x7f9411cfe3e0) = 23197
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f940f1ca000
mprotect(0x7f940f1cc000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f940f3cc988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23198], tls=0x7f940f3ccb20, child_tidptr=0x7f9411cfe3e0) = 23198
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f940efc7000
mprotect(0x7f940efc9000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f940f1c9988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23199], tls=0x7f940f1c9b20, child_tidptr=0x7f9411cfe3e0) = 23199
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f940edc4000
mprotect(0x7f940edc6000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f940efc6988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23200], tls=0x7f940efc6b20, child_tidptr=0x7f9411cfe3e0) = 23200
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f940ebc1000
mprotect(0x7f940ebc3000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f940edc3988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23201], tls=0x7f940edc3b20, child_tidptr=0x7f9411cfe3e0) = 23201
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
brk(0x55555592f000)                     = 0x55555592f000
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f940e9be000
mprotect(0x7f940e9c0000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f940ebc0988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23202], tls=0x7f940ebc0b20, child_tidptr=0x7f9411cfe3e0) = 23202
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f940e7bb000
mprotect(0x7f940e7bd000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f940e9bd988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23203], tls=0x7f940e9bdb20, child_tidptr=0x7f9411cfe3e0) = 23203
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
mmap(NULL, 2109440, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f940e5b8000
mprotect(0x7f940e5ba000, 2101248, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
clone(child_stack=0x7f940e7ba988, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|0x400000, parent_tid=[23204], tls=0x7f940e7bab20, child_tidptr=0x7f9411cfe3e0) = 23204
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x55555591c460, FUTEX_WAKE_PRIVATE, 1) = 1
stat("/var/ssl", 0x7ffc3f587330)        = -1 ENOENT (No such file or directory)
stat("/usr/share/ssl", 0x7ffc3f587330)  = -1 ENOENT (No such file or directory)
stat("/usr/local/ssl", 0x7ffc3f587330)  = -1 ENOENT (No such file or directory)
stat("/usr/local/openssl", 0x7ffc3f587330) = -1 ENOENT (No such file or directory)
stat("/usr/local/etc/openssl", 0x7ffc3f587330) = -1 ENOENT (No such file or directory)
stat("/usr/local/share", {st_mode=S_IFDIR|0755, st_size=40, ...}) = 0
stat("/usr/local/share/cert.pem", 0x7ffc3f587310) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/certs.pem", 0x7ffc3f587310) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/ca-bundle.pem", 0x7ffc3f587310) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/cacert.pem", 0x7ffc3f587310) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/ca-certificates.crt", 0x7ffc3f587310) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/certs/ca-certificates.crt", 0x7ffc3f587310) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/certs/ca-root-nss.crt", 0x7ffc3f587310) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/certs/ca-bundle.crt", 0x7ffc3f587310) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/CARootCertificates.pem", 0x7ffc3f587310) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/tls-ca-bundle.pem", 0x7ffc3f587310) = -1 ENOENT (No such file or directory)
stat("/usr/local/share/certs", 0x7ffc3f5875e0) = -1 ENOENT (No such file or directory)
stat("/usr/lib/ssl", 0x7ffc3f587330)    = -1 ENOENT (No such file or directory)
stat("/usr/ssl", 0x7ffc3f587330)        = -1 ENOENT (No such file or directory)
stat("/etc/openssl", 0x7ffc3f587330)    = -1 ENOENT (No such file or directory)
stat("/etc/pki/ca-trust/extracted/pem", 0x7ffc3f587330) = -1 ENOENT (No such file or directory)
stat("/etc/pki/tls", 0x7ffc3f587330)    = -1 ENOENT (No such file or directory)
stat("/etc/ssl", {st_mode=S_IFDIR|0755, st_size=172, ...}) = 0
stat("/etc/ssl/cert.pem", {st_mode=S_IFREG|0644, st_size=211749, ...}) = 0
stat("/etc/ssl/certs", {st_mode=S_IFDIR|0755, st_size=13418, ...}) = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} ---
rt_sigaction(SIGSEGV, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f9411b1b2c3}, NULL, 8) = 0
rt_sigreturn({mask=[]})                 = 140273926059424
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} ---
+++ killed by SIGSEGV +++
zsh: segmentation fault  strace ./target/debug/reproducer
@WhyNotHugo WhyNotHugo added the C-bug Category: This is a bug. label Feb 1, 2023
@WhyNotHugo
Copy link
Author

Huh, interesting.

Using the cargo/rust version shipped with Alpine packages (1.67.0) it all works fine.

Using the cargo/rust version installed via rustup (1.67.0) it also segfaults.

@WhyNotHugo
Copy link
Author

I've had issues with the binaries that rustup installs on musl before, I think there might be something broken in the way that these are compiled.

@WhyNotHugo
Copy link
Author

Yeah, here it is: #108878

On aarch64-unknown-linux-musl, binaries somehow link to glibc, even if it's not present on the host.

This is x86_64-unknown-linux-musl; I wonder if the issues are somehow related.

@WhyNotHugo WhyNotHugo changed the title Segfault when using reqwests with nightly Segfault when using async with nightly on linux-musl Feb 1, 2023
@WhyNotHugo WhyNotHugo changed the title Segfault when using async with nightly on linux-musl Segfault when using async on linux-musl Feb 2, 2023
@WhyNotHugo
Copy link
Author

Updating title since this happens on both nightly and stable.

@WhyNotHugo
Copy link
Author

I'm starting to suspect that this is just a duplicate of #107566, reproduced under entirely different circumstances.

@catamorphism
Copy link
Contributor

My feeling is that this isn't a duplicate. The underlying cause might be the same (or this could be an interaction between the same underlying cause and some infelicity in how async fn is implemented), but producing binaries that segfault is a different (and worse!) behavior than producing binaries that won't run because of linker or loader errors. Possibly you're seeing the segfault here because some other code is failing to gracefully handle a loader error.

Unfortunately I don't have a solution (other than to use rustc from your package manager or possibly build your project with RUSTFLAGS="-Ctarget-feature=-crt-static", as you discovered), I'm just doing some research on what bugs people are running into with musl targets. While the same workarounds may address both problems for you, the issues the implementors should fix may be different, which is why I think this shouldn't be closed as a duplicate.

It should, though, be labeled as O-musl at least.

@WhyNotHugo
Copy link
Author

Still an issue with rustc 1.71.0-nightly (2c41369ac 2023-05-13).

@SpaceCat-Chan
Copy link

SpaceCat-Chan commented Nov 19, 2023

this seems to be solved as of 1.76.0-nightly, and possibly earlier, tested both with and without RUSTFLAGS="-Ctarget_feature=-crt_static" using rustup installed from alpine's rustup package. tested on my x86 laptop.

$ rustc --version          
rustc 1.76.0-nightly (2c1b65ee1 2023-11-11)

@WhyNotHugo
Copy link
Author

WhyNotHugo commented Jan 31, 2024

I can't confirm whether the issue is fixed; the original example does not compile for me with the compiler shipped via rustup. I reproduced with:

mkdir reproducer
cd reproducer
cargo init
cat > Cargo.toml <<EOF
[package]
name = "reproducer"
version = "0.1.0"
edition = "2021"

[dependencies]
reqwest = "0.11.14"
tokio = { version = "1.25.0", features = ["rt", "macros", "rt-multi-thread"] }
EOF
cat > src/main.rs <<EOF
#[tokio::main]
async fn main() {
    reqwest::get("https://www.rust-lang.org")
        .await
        .unwrap()
        .text()
        .await
        .unwrap();
}
EOF
cargo build
./target/debug/reproducer
echo $?

When using RUSTUP_TOOLCHAIN=stable, it fails to build with:

error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/bin:/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/bin/self-contained:/home/hugo/.local/state/cargo/bin:/home/hugo/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" VSLANG="1033" "cc" "-m64" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/rcrt1.o" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crti.o" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtbeginS.o" "/tmp/rustc686cXi/symbols.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.17wi9h49iouljtsq.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.186zaen3pp28khhw.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.1ecagxsmiadfth8g.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.1g38ax284d2ala9d.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.1jriiksqcxgp6pdw.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.1uo591xyubbb2p4k.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.1xju9r0z286e9n62.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.1xu8w3aqtsd14qal.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.1zju810lcihehoqx.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.23yji0u1ph0wid4z.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.25p58cvno2ab4hvo.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.26r1idnaxyj9gsh3.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.2a19ov5d7s9oplep.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.2hylfuovdchq9i6s.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.2kdd8mzrhzf0b4q0.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.2ru9b6vk8b829how.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.2x58d7kqju0b1xnd.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.2zdhceywo4ld1geq.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.378pknww7bbkcpgz.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.3dikzs7wvwm72mj2.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.3ox9ml9355m3puag.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.3tnf82etl68tbbk2.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.3towdijb9ysnv63v.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.3vn9pbp7gxot5vvk.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.3w7uts8tbklk1z.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.43jukzlh2d7glcf7.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.44d30cuejoimo02e.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.44eonarjihjsswpz.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.4jonucq5om2b0l6s.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.4l6d0mu62ipji0oq.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.4qawjv8h42fxnb21.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.4shyi361lyshhwg9.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.4w1wbs362ww0gvx1.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.4y78apwvx2jpn0tf.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.4zov6lyleviho0qt.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.53m4p3oq86w9qe52.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.59jqg9jsgvcyly06.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.5b8jj8p7txeypjfe.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.c4frv78910zdzum.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.fcr1rplw3zchlik.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.hmcgzn3sxp6k4oe.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.np2oub03z8671ua.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.nz6uejp4gyenp0c.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.sj1ub2azcairp43.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.t7bzlu6eh85aevn.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.wzjxc8er1koyjec.rcgu.o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4.2x7u7j0fjtqhe1xe.rcgu.o" "-Wl,--as-needed" "-L" "/home/hugo/tmp/reproducer/target/debug/deps" "-L" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib" "-Wl,-Bstatic" "/home/hugo/tmp/reproducer/target/debug/deps/libreqwest-3ea12dc2f08dac62.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/librustls_pemfile-358e8541663f6ac8.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libhyper_tls-a4ffe278f7afce79.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libserde_urlencoded-b98b6cc53bdab691.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libryu-7133b9daa716b891.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libbase64-31003f5af43eab4d.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libipnet-3ed37c93f8500918.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libtokio_native_tls-b838568714f29141.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libmime-de4daa82c0f9e126.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libencoding_rs-1d9ffcf8819f478c.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libserde-354e909bf15e1e33.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libnative_tls-f833bb80bd454dac.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libopenssl_probe-93e1c52c7a8b731c.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libopenssl-802245dcfb15a44e.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libbitflags-81ecc7d954917502.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libforeign_types-942e261193fcb016.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libforeign_types_shared-8a60851268ca8955.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libcfg_if-eaf8763d6ee0374b.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libopenssl_sys-62b29eae71ac0dec.rlib" "-lssl" "-lcrypto" "/home/hugo/tmp/reproducer/target/debug/deps/libhyper-638c84ad95a90960.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libwant-2e1552a3ca71a5f6.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libtry_lock-42bd4a7d88d275a2.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libhttparse-72c445abed2c119b.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libh2-12c85d8e737c60c1.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libindexmap-1b3ae4d1e875995d.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libequivalent-e9d3a3bc5ade8f5c.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libhashbrown-f399088ac64b1b62.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libslab-8bfa35f08a737d15.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libtokio_util-ed321ff07bacd766.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libfutures_sink-433d08bdcabb8a36.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libtower_service-742dbe85517c2ff2.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libtracing-aef44165c4eb0a4f.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libtracing_core-ee0c82f694d1bc06.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libonce_cell-7151d89def0e9358.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libfutures_channel-b57de5810fe715ef.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libfutures_util-47751190d3054bce.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libfutures_task-0bd09eb8c6094b98.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libpin_utils-be396d5aae48b5ef.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libsync_wrapper-59dca1206762352b.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libhttp_body-37d1886ba192071a.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/liblog-456fc60d6199be74.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libfutures_core-57287b7a3d4145e8.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/liburl-00aefdbd253b2b7c.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libidna-bfeab484f2d178af.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libunicode_normalization-8d2656d5f0a0c312.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libtinyvec-267df5224047a7d1.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libtinyvec_macros-ef11fa124771bbb2.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libunicode_bidi-ab7f21e86a91e4c5.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libform_urlencoded-d31ad03edb8f51cd.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libpercent_encoding-175f394c520ed285.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libhttp-dc3285be677cd4d6.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libitoa-c8af5e52dc97ae08.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libfnv-c1aef351075344a5.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libtokio-f620f7fb0e62f680.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libnum_cpus-18c1233d61326965.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libsocket2-6410a0c7084ee1e9.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libbytes-9096aed193024b1e.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libmio-02da20cfbcae03a5.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/liblibc-7f0547d021c48044.rlib" "/home/hugo/tmp/reproducer/target/debug/deps/libpin_project_lite-607aa1b7d465e3b5.rlib" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd-11c02606063fb1b5.rlib" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libpanic_unwind-527b1ade0207850b.rlib" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libobject-5c6479882291983e.rlib" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libmemchr-b30d7598b031e855.rlib" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libaddr2line-7bdd9f1650697dee.rlib" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libgimli-af6e6b96893335a7.rlib" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/librustc_demangle-61a774fd0ca56cef.rlib" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd_detect-0bdaa2154e535182.rlib" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libhashbrown-40daaa64e7b3ff16.rlib" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/librustc_std_workspace_alloc-51b0c25ea806d020.rlib" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libminiz_oxide-503b1c30e4fe986c.rlib" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libadler-0dfa15d5b98a6f2c.rlib" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libunwind-7e3d215879e752d5.rlib" "-lunwind" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libcfg_if-f91de774775af47a.rlib" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/liblibc-a172c9da7a8c39aa.rlib" "-lc" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/liballoc-05ed26095d7bae0a.rlib" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/librustc_std_workspace_core-940bcdced839ada6.rlib" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libcore-ece58c607aadf4ad.rlib" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libcompiler_builtins-cfd03998b63f49b3.rlib" "-Wl,-Bdynamic" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-nostartfiles" "-L" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib" "-L" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained" "-o" "/home/hugo/tmp/reproducer/target/debug/deps/reproducer-eb8a48cacbdb2ca4" "-Wl,--gc-sections" "-static-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtendS.o" "/home/hugo/.local/state/rustup/toolchains/stable-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtn.o"
  = note: /usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lssl: No such file or directory
          /usr/lib/gcc/x86_64-alpine-linux-musl/13.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lcrypto: No such file or directory
          collect2: error: ld returned 1 exit status
          

error: could not compile `reproducer` (bin "reproducer") due to previous error

With RUSTUP_TOOLCHAIN=system, it builds and runs fine.

@WhyNotHugo
Copy link
Author

WhyNotHugo commented Jan 31, 2024

Apparently, Alpine patches the rust to avoid exactly this error, but I've no idea about the context:

https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/main/rust/gcc-eh-libunwind.patch?ref_type=heads

Never mind, different error.

@nekopsykose
Copy link

When using RUSTUP_TOOLCHAIN=stable, it fails to build with:

this is now a loud failure that it failed to find libssl.a for the default static link instead of producing a broken binary (and looks intended), and seems unrelated to the original issue somewhat

@WhyNotHugo
Copy link
Author

I'm aware that it's a different issue. I mention it because it blocks from actually reproducing the original sample here and confirming whether it now works or not.

Yeah, it's trying to statically link by default. Looks like that issue is not yet resolved: #59302

Building with RUSTFLAGS="-Ctarget-feature=-crt-static" RUSTUP_TOOLCHAIN=stable cargo build works and produces a sane binary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-musl Target: The musl libc
Projects
None yet
Development

No branches or pull requests

5 participants