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

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

Open
etam opened this issue Aug 27, 2023 · 4 comments
Open

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

etam opened this issue Aug 27, 2023 · 4 comments

Comments

@etam
Copy link
Contributor

etam commented Aug 27, 2023

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
Copy link
Contributor

aszlig commented Oct 13, 2023

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

ip2unix/meson.build

Lines 85 to 92 in 1083369

gen_ldscript = [python, script_gensyms, '--ldscript']
ldscript = custom_target('ldscript', input: lib_sources, output: 'ldscript',
command: gen_ldscript + gen_extra_args, capture: true)
lib_ldflags += [
'-Wl,--version-script,@0@'.format(sym_map.full_path()),
ldscript.full_path()
]

@aszlig
Copy link
Contributor

aszlig commented Jul 7, 2024

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

@aszlig
Copy link
Contributor

aszlig commented Jul 7, 2024

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
Copy link
Contributor

aszlig commented Jul 7, 2024

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.

aszlig added a commit that referenced this issue Jul 7, 2024
Right now, link-time optimisation doesn't work and produces symbols with
null references with our linker script.

For example without LTO:

  $ nm -D result/lib/libip2unix.so | grep socket
  000000000000fed0 T socket

With LTO enabled however, we get the following:

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

I haven't managed to find out why *exactly* this happens, but since we
don't have a fix yet, let's at least make sure users get an error
message early on instead of a crash.

Signed-off-by: aszlig <aszlig@nix.build>
Issue: #33
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