nixcloud / ip2unix

Turn IP sockets into Unix domain sockets
GNU Lesser General Public License v3.0
357 stars 10 forks source link

Building with "-flto=auto" causes apps to crash #33

Open etam opened 1 year ago

etam commented 1 year ago

In openSUSE all packages have by default enabled LTO (but in cases like this it can be easily disabled). Fortunately this is caught by the tests, because helpers/helper_accept_no_peer_addr crashes and a test fails.

aszlig commented 11 months ago

This is probably because we're using a custom --version-script:

https://github.com/nixcloud/ip2unix/blob/1083369be4c2a09256f06507bacdf2accadd8d78/meson.build#L85-L92

aszlig commented 2 months ago

Okay, just tested this and it's not because of the --version-script, investigating...

aszlig commented 2 months ago

Sooo, this essentially boils down to a nullptr dereference because the symbols actually resolve to null:

With LTO:

$ nm -D result/lib/libip2unix.so | grep socket
0000000000000000 A socket

Without LTO:

$ nm -D result/lib/libip2unix.so | grep socket
000000000000fed0 T socket
aszlig commented 2 months ago

Okay, backtracking on what I wrote earlier, it is the linker script indeed. I accidentally run a isolated test which ran into essentially a no-op without the linker script.