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

Stack smashing protection causing issues with Windows targets #12

Open
FrancisRussell opened this issue Sep 12, 2022 · 2 comments
Open

Comments

@FrancisRussell
Copy link

FrancisRussell commented Sep 12, 2022

I've been using audiopus_sys 0.2.2 via audiopus 0.3.0-rc.0, In my Cargo.toml, I've used the static option to ensure that libopus is built from source. In an Ubuntu environment I've been cross compiling my project for the x86_64-pc-windows-gnu and i686-pc-windows-gnu targets. However, I have encountered linking issues due to stack-smashing protection (SSP). These manifest as follows:

  = note: /target/i686-pc-windows-gnu/debug/deps/libaudiopus_sys-b661dfe0e9f65081.rlib(opus_decoder.c.obj): In function `opus_decoder_get_size':
          /cargo/registry/src/github.com-1ecc6299db9ec823/audiopus_sys-0.2.2/opus/src/opus_decoder.c:103: undefined reference to `__stack_chk_guard'
          /cargo/registry/src/github.com-1ecc6299db9ec823/audiopus_sys-0.2.2/opus/src/opus_decoder.c:114: undefined reference to `__stack_chk_guard'
          /cargo/registry/src/github.com-1ecc6299db9ec823/audiopus_sys-0.2.2/opus/src/opus_decoder.c:114: undefined reference to `__stack_chk_fail'
          /target/i686-pc-windows-gnu/debug/deps/libaudiopus_sys-b661dfe0e9f65081.rlib(opus_decoder.c.obj): In function `opus_decoder_init':
          /cargo/registry/src/github.com-1ecc6299db9ec823/audiopus_sys-0.2.2/opus/src/opus_decoder.c:117: undefined reference to `__stack_chk_guard'
          /cargo/registry/src/github.com-1ecc6299db9ec823/audiopus_sys-0.2.2/opus/src/opus_decoder.c:157: undefined reference to `__stack_chk_guard'
          /cargo/registry/src/github.com-1ecc6299db9ec823/audiopus_sys-0.2.2/opus/src/opus_decoder.c:157: undefined reference to `__stack_chk_fail'
          /target/i686-pc-windows-gnu/debug/deps/libaudiopus_sys-b661dfe0e9f65081.rlib(opus_decoder.c.obj): In function `opus_decode_frame':
          /cargo/registry/src/github.com-1ecc6299db9ec823/audiopus_sys-0.2.2/opus/src/opus_decoder.c:222: undefined reference to `__stack_chk_guard'
          /cargo/registry/src/github.com-1ecc6299db9ec823/audiopus_sys-0.2.2/opus/src/opus_decoder.c:624: undefined reference to `__stack_chk_guard'
          /cargo/registry/src/github.com-1ecc6299db9ec823/audiopus_sys-0.2.2/opus/src/opus_decoder.c:624: undefined reference to `__stack_chk_fail'

From what I can tell, the Opus library will compile using SSP functionality by default which is what causes these references. I was able to work around the issue by creating a .cargo/config.toml as follows:

[target.x86_64-pc-windows-gnu]
rustflags = [ "-C", "link-arg=-lssp" ]

[target.i686-pc-windows-gnu]
rustflags = [ "-C", "link-arg=-lssp" ]

I also have a build for x86-64 musl, but did not encounter this issue.

@WcaleNieWolny
Copy link

I have the same issue

@WcaleNieWolny
Copy link

I have a dirty fix on my fork. You can use it by adding this to Cargo.toml

[patch.crates-io]
audiopus_sys = { git = "https://github.com/WcaleNieWolny/audiopus_sys.git", branch = "stable-changes" }

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

2 participants