0

I had an old app that I need to maintain. Thousands of lines of code.

When I switched to the gcc 7.3 compiler and I enabled -flto application started to crash o exit:

(gdb) bt
#0  0x00000000 in ?? ()
#1  0x1ee0c6b0 in ?? () from /lib/libc.so.6
#2  0x1ee0c840 in exit () from /lib/libc.so.6
#3  0x1edf0d5c in ?? () from /lib/libc.so.6
#4  0x1edf0f10 in __libc_start_main () from /lib/libc.so.6
#5  0x00000000 in ?? ()

When I removed -flto option app stopped crashing.

I've traced that unused static variable in a body of one of functions caused the problem:

  static std::vector<C_Param*>    vpParam;

When I removed 'static' or removed variable at all app stopped crashing.

This is very strange to me because the variable is not used and only happens with the -flto option.

What could be the main cause?

Jakub
  • 19
  • 5
  • Undefined behavior? Heap corruption? Compiler bug? It could be any of those. It's not really possible to tell which one it is based on the information you supplied. You could try running it under valgrind and see if it reports any errors that make sense to you. –  Oct 27 '20 at 09:32
  • Heh... It is not so easy. The issue is reproducible on cross platform where I cannot use valgrind. I compiled app on x86 and it does not reproduce and valgrind shows nothing. – Jakub Oct 27 '20 at 09:44
  • Can you try a more recent compiler? – ssbssa Oct 27 '20 at 11:22
  • It cant be done. I thought that it might be this: https://stackoverflow.com/questions/47456530/lto-causes-crash-in-standard-library but code is shown there does not crash on my system. I checked version of binutils: 2.23.2 – Jakub Oct 27 '20 at 11:33

0 Answers0