Coder Social home page Coder Social logo

Comments (13)

Wilfred avatar Wilfred commented on June 1, 2024

Hmm, I can reproduce on my system too. gdb doesn't show anything useful:

$ gdb ./difft
Reading symbols from ./difft...
(No debugging symbols found in ./difft)
(gdb) run --version
Starting program: /tmp/difft --version
                                                                                            
Program received signal SIGSEGV, Segmentation fault.
0x00000000000a56a6 in ?? ()
(gdb) bt
#0  0x00000000000a56a6 in ?? ()
#1  0x00007ffff43845a5 in ?? ()
#2  0x00007ffff3e69fbb in ?? ()
#3  0x00007ffff3e6ba30 in ?? ()
#4  0x00007ffff4573061 in ?? ()
#5  0x00007ffff3f3c390 in ?? ()
#6  0x00007ffff4573086 in ?? ()
#7  0x00007ffff4573069 in ?? ()
#8  0x0000000000000000 in ?? ()

although that 0x0 in #8 does look suspicious.

from difftastic.

Wilfred avatar Wilfred commented on June 1, 2024

Possibly related: rust-lang/rust#95926

Maybe musl builds should use rust 1.61 to avoid that issue.

from difftastic.

Wilfred avatar Wilfred commented on June 1, 2024

rust-lang/rust#74757 also shows a very similar backtrace.

from difftastic.

Wilfred avatar Wilfred commented on June 1, 2024

What's really bizarre here is that the musl builds are dynamically linked. This is wrong, and differs from the rust default (musl targets are statically linked).

$ ldd difft
	linux-vdso.so.1 (0x00007fff1a376000)
	libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f6283400000)
	libm.so.6 => /usr/lib/libm.so.6 (0x00007f6287ae0000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007f6283000000)
	/usr/lib64/ld-linux-x86-64.so.2 (0x00007f6287c01000)
	libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f6287abb000)

This is slightly different from the normal linux-gnu target, which also has libpthread and libdl, but the musl build is definitely dynamically linked for some reason.

from difftastic.

agateau avatar agateau commented on June 1, 2024

This is slightly different from the normal linux-gnu target, which also has libpthread and libdl, but the musl build is definitely dynamically linked for some reason.

For what it's worth: I built Clyde, which is Rust-based and provides a musl static binary for Linux. To make it statically linked I had to add this to the build script:

export RUSTFLAGS='-C target-feature=+crt-static'

from difftastic.

Wilfred avatar Wilfred commented on June 1, 2024

Thanks, I'll try that. I don't understand why I'm not getting static linking, rust should statically link musl builds by default I believe:

$ cargo new demo      
     Created binary (application) `demo` package

$ cd demo       
$ cargo build --release --target x86_64-unknown-linux-musl                                                                       
   Compiling demo v0.1.0 (/tmp/demo)
    Finished release [optimized] target(s) in 0.32s

$ ldd target/x86_64-unknown-linux-musl/release/demo      
	statically linked

from difftastic.

agateau avatar agateau commented on June 1, 2024

That's odd indeed. Maybe the behavior is different in your example because the demo project does not have any dependency?

from difftastic.

Wilfred avatar Wilfred commented on June 1, 2024
$ cross build --release --target x86_64-unknown-linux-musl

$ ldd target/x86_64-unknown-linux-musl/release/difft
	statically linked

$ ./target/x86_64-unknown-linux-musl/release/difft --version
Difftastic 0.52.0 (6805939c6 2023-09-28)

I can't replicate this with cross locally. I'm inclined to blame the upload-rust-binary action. It might also be easier to do more work in shell scripts in this repo, as it's much easier to reproduce issues than re-running GiHub actions over and over.

from difftastic.

Wilfred avatar Wilfred commented on June 1, 2024

I'm wondering if something is picking up an old version of cross. cross-rs/cross#902 looks relevant.

from difftastic.

Wilfred avatar Wilfred commented on June 1, 2024

Probably worth filing an issue on upload-rust-binary-action to see if I've missed anything.

from difftastic.

nekopsykose avatar nekopsykose commented on June 1, 2024

This is slightly different from the normal linux-gnu target, which also has libpthread and libdl, but the musl build is definitely dynamically linked for some reason.

that's actually not correct anymore. glibc 2.34 removed dynamic libdl.so and libpthread.so, so for new binaries you don't see them anymore- there is only a stub empty .a. see https://developers.redhat.com/articles/2021/12/17/why-glibc-234-removed-libpthread for some details

what that means is, that ldd list means the binary has all the libs you would expect for a -crt-static(dynamic) *-linux-gnu(glibc) triplet build. i.e. it's not linked to musl at all (or probably it somehow ends up creating a frankenstein binary that on the surface looks like it links glibc; like having all the glibc libs in NEEDED but actually the musl static binary startup code). perhaps something went wrong with the configured rustup toolchain in your case? i haven't seen this specific failure case before, so it's probably related to some default target or the cross setup.

from difftastic.

nekopsykose avatar nekopsykose commented on June 1, 2024

ah, yeah that cross issue above looks very related

from difftastic.

Wilfred avatar Wilfred commented on June 1, 2024

Reproduces on CI now, fortunately: https://github.com/Wilfred/difftastic/actions/runs/6986277695/job/19011557098 (after 6051f05).

from difftastic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.