bzip2-rs icon indicating copy to clipboard operation
bzip2-rs copied to clipboard

bz_internal_error exported

Open nwalfield opened this issue 3 years ago • 1 comments

I develop rpm-sequoia, which is a Rust crate that implements rpm's OpenPGP API in terms of Sequoia PGP. (More details, unrelated to this issue, are described in this rpm issue).

rpm-sequoia should only export the rpm's PGP API. Unfortunately, a number of additional symbols are leaked by dependencies. Specifically, any symbols that have the #[no_mangle] attribute appear to be exported. bzip2-sys marks bz_internal_error like this, and thus it is exported by the library:

$ nm --defined-only --extern-only /tmp/rpm-sequoia/debug/librpm_sequoia.so | grep bz
0000000000361fa0 T bz_internal_error

In turns out that rpm-sequoia doesn't actually need compression support so I was able to workaround this issue by disabling that feature. But, this issue may trip up others.

nwalfield avatar May 03 '22 10:05 nwalfield

It also affects the Sequoia Octopus: https://gitlab.com/sequoia-pgp/sequoia-octopus-librnp/-/issues/68

$ cp $CARGO_TARGET_DIR/debug/libsequoia_octopus_librnp.so libsequoia_octopus_librnp.so
$ NEEDLESSLY_EXPORTED_SYMBOLS="$(readelf --dyn-syms libsequoia_octopus_librnp.so | grep -v UND | grep -v rnp_ | grep DEFAULT)"
$ echo "$NEEDLESSLY_EXPORTED_SYMBOLS"
   375: 0000000000f9e3a0   101 FUNC    GLOBAL DEFAULT   12 bz_internal_error
   433: 0000000001008d40   310 FUNC    GLOBAL DEFAULT   12 rust_eh_personality

(Excerpt from our CI build log: https://gitlab.com/sequoia-pgp/sequoia-octopus-librnp/-/jobs/3225827176#L432)

teythoon avatar Oct 26 '22 09:10 teythoon