2

Hello dudes and dudettes!

When I compile my C++ program on Ubuntu (a VirtualMachine in VirtualBox), which previously ran without errors under Windows, I get a segmentation fault.

/usr/bin/ld: BFD (GNU Binutils for Ubuntu) 2.38 assertion fail ../../bfd/reloc.c:8580
/home/rafael/projects/Send06/lib/x86-64//libstar-api.a(dwzh.o):fake:(.idata$2+0x0): dangerous relocation: collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped
compilation terminated.
make: *** [Makefile:382: Send06] Error 1

I understand what a segmentation fault is, but I do not comprehend how this could happen in an external library. The source code of the library is not available.

Steps I took:

  1. Compiled a "Hello World!" program. --> no errors.
  2. Enlarged the virtual RAM. --> no changes.

Can you help me? Thanks in advance.


System: Windows 10

VM: Ubuntu 22.04.01 LTS

IDE: Qt Creator 8

Compiler: gcc 11.2.0

Barmar
  • 741,623
  • 53
  • 500
  • 612
rafa
  • 35
  • 5
  • Does the command "ld -v" work in a terminal? – Girspoon Aug 05 '22 at 16:07
  • Maybe this: https://stackoverflow.com/questions/57051568/collect2-fatal-error-ld-terminated-with-signal-11-segmentation-fault – Barmar Aug 05 '22 at 16:07
  • Can you compile other programs? – JarMan Aug 05 '22 at 16:08
  • See also https://stackoverflow.com/questions/19532826/what-does-a-dangerous-relocation-error-mean – Barmar Aug 05 '22 at 16:08
  • @JarMan Yes, it is possible. @Barmar I already looked at these questions and performed suggested solutions. @Girspoon Yes, it works and says: ```GNU ld (GNU Binutils for Ubuntu) 2.38``` – rafa Aug 05 '22 at 16:14
  • This looks like an assertion failure internal to the linker. It may be a bug in the linker or your linker is broken in some way. – user17732522 Aug 05 '22 at 16:19
  • 1
    It is triggering [this assertion](https://github.com/bminor/binutils-gdb/blob/binutils-2_38-branch/bfd/reloc.c#L8580). You can see prior in the function that `error_message` is supposed to be set if this line is reached. You can also see in the definition of `BFD_ASSERT` and in the source for `ld` that the assertions are reported and generation of a binary suppressed, but the linker does not stop on the assertion failure. As a consequence it continues execution and then tries to print a warning about the dangerous relocation with `error_message` a null pointer, causing the segmentation fault. – user17732522 Aug 05 '22 at 16:37
  • 1
    I would recommend trying this with an up-to-date version of binutils and if it still fails reporting it as a bug if you can reduce it to a useful bug report. – user17732522 Aug 05 '22 at 16:37

1 Answers1

0

I confused a Linux with a Windows library!

The answer is quite simple. I had a folder with libraries with the ending xyz.lib and xyz.a. So I thought, .lib for Windows and .a for Linux. However, there was seperate distribution of libraries for Linux. Now everything works.

Thank you for your input!

rafa
  • 35
  • 5