[Bug ld/31895] New: LD segfault in libbfd

2024-06-14 Thread corentin.silvapere...@4d-virtualiz.com
https://sourceware.org/bugzilla/show_bug.cgi?id=31895

Bug ID: 31895
   Summary: LD segfault in libbfd
   Product: binutils
   Version: 2.34
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: ld
  Assignee: unassigned at sourceware dot org
  Reporter: corentin.silvapere...@4d-virtualiz.com
  Target Milestone: ---

Hi,

Recently i have some problems while compiling softwares. I'm on Ubuntu 20.04
but i had the same problem on Ubuntu 24.04. I often have this message
"collect2: fatal error: ld terminated with signal 11 [Erreur de segmentation],
core dumped" when compiling, and i've looked in dmesg to find an explanation.
Here's what dmesg gave me :

[27357.364350] ld[516146]: segfault at 1fb79 ip 7f108e72b0f6 sp
7ffc282a3030 error 4 in libbfd-2.34-system.so[7f108e6dc000+b1000]
[27357.364357] Code: ed 75 27 e9 6a d3 ff ff 0f 1f 40 00 0f b6 42 19 83 e3 01
01 db 83 e0 fd 09 c3 88 5a 19 48 8b 6d 00 48 85 ed 0f 84 48 d3 ff ff <0f> b6 55
18 48 89 e8 80 fa 07 75 08 48 8b 45 28 0f b6 50 18 45 31

[27599.972532] ld[543684]: segfault at 0 ip 7f65d770fac4 sp
7ffccb357fe8 error 4 in libbfd-2.34-system.so[7f65d76de000+b1000]
[27599.972541] Code: 48 21 f0 48 83 c1 01 48 31 d0 0f b6 51 ff 84 d2 75 d8 89
c0 c3 90 31 c0 c3 66 66 2e 0f 1f 84 00 00 00 00 00 66 90 f3 0f 1e fa <0f> b6 17
48 8d 77 01 b8 05 15 00 00 84 d2 74 2c 0f 1f 40 00 48 89

[28912.103007] ld[712964]: segfault at 0 ip 7f9baddfbac4 sp
7ffdcea71148 error 4 in libbfd-2.34-system.so[7f9baddca000+b1000]
[28912.103016] Code: 48 21 f0 48 83 c1 01 48 31 d0 0f b6 51 ff 84 d2 75 d8 89
c0 c3 90 31 c0 c3 66 66 2e 0f 1f 84 00 00 00 00 00 66 90 f3 0f 1e fa <0f> b6 17
48 8d 77 01 b8 05 15 00 00 84 d2 74 2c 0f 1f 40 00 48 89

[29086.396713] ld[716997]: segfault at c9 ip 7f330b1b4133 sp
7ffc8ea24e90 error 4 in libbfd-2.34-system.so[7f330b165000+b1000]
[29086.396719] Code: 18 45 31 e4 45 31 ed 80 fa 05 75 0b 48 8b 50 28 4c 8b 68
30 44 8b 22 41 8b 56 20 0f b6 58 19 4c 89 fe 48 89 ef e8 8d 3d fb ff <45> 8b 46
20 0f b6 45 18 d0 eb 83 e3 01 48 89 ea 4d 01 c7 3c 07 74



I've already tried to re-install binutils, gcc, installed a superior version of
gcc (was on 9.4.0 and tried 10.5.0), and did some research about those errors
but i can't find anything useful. Maybe you have an idea ?

Best regards

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/31895] LD segfault in libbfd

2024-06-18 Thread corentin.silvapere...@4d-virtualiz.com
https://sourceware.org/bugzilla/show_bug.cgi?id=31895

--- Comment #2 from Corentin Silva Pereira 
 ---
(In reply to Nick Clifton from comment #1)

Hi Nick,

Just so you can have more context, our software is developped with QT C++, and
we have a lot of .o and .so files to link with the main software of our
solution. One command can link like a 100 files/lib. This is the one that's
causing this crash.

Unfortunately, i can't give you the ld command i use because the code belongs
to my company and i'm not authorized to give it. Although i tried to compile
binutils 2.34 manually and i managed to cause the segfault within GDB.

Here's what i got :

Program received signal SIGSEGV, Segmentation fault.
0x55600b03 in elf_link_add_object_symbols (info=,
abfd=) at elflink.c:5262
5262  non_ir_ref_dynamic = h->root.non_ir_ref_dynamic;
(gdb) bt
#0  0x55600b03 in elf_link_add_object_symbols (info=,
abfd=) at elflink.c:5262
#1  bfd_elf_link_add_symbols (abfd=, info=) at
elflink.c:5809
#2  0x5559c484 in load_symbols (place=,
entry=0x5580f630) at ldlang.c:3098
#3  load_symbols (entry=0x5580f630, place=) at ldlang.c:2959
#4  0x5559cebf in open_input_bfds (s=0x5580f630,
mode=mode@entry=OPEN_BFD_NORMAL) at ldlang.c:3568
#5  0x5559f518 in lang_process () at ldlang.c:7649
#6  0x555a32a7 in main (argc=225, argv=0x7fff9358) at
./ldmain.c:444

I tried to give -g -O0 to all binutils so i can have all the symbols, but i
still can't print h or print h->root within GDB.

> The 2.34 release of the binutils is quite old now.  Are you able to update
> to a newer version ? 
To answer your question, we are porting the software to Ubuntu 24.04 which uses
a more recent version of binutils but i still have the problem on Ubuntu 24.04
so i don't think it is very related to the version.

Are there elements i can add to the binutils compiling arguments to give you
more information ? For example, something to generate a coredump or something
to read those optimized out values

Best regards

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/31895] LD segfault in libbfd with --as-needed

2024-06-19 Thread corentin.silvapere...@4d-virtualiz.com
https://sourceware.org/bugzilla/show_bug.cgi?id=31895

--- Comment #5 from Corentin Silva Pereira 
 ---
(In reply to Nick Clifton from comment #3)

Hi Nick,

Thanks for the responses, i'm currently looking into everything you've told me,
i'll get back to this post if i have some more informations to give you. 


(In reply to Alan Modra from comment #4)
Hi Alan,

> Your dmesg dumps show segfaults on three different pieces of code.  Are they 
> all > the same libbfd-2.34-system.so?

When the segfault occurred, i was using the official ubuntu 20.04 packet of
binutils, so i'd say they're all from the same.


> If you see the problem with ubuntu 24.04 then that would imply there is a 
> problem with binutils-2.42, assuming you aren't using some other linker 
> accidentally.

I have a fresh install of Ubuntu 24.04, all i have on it is my company's
software and i'm sure we don't use an other linker.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/31895] LD segfault in libbfd with --as-needed

2024-06-21 Thread corentin.silvapere...@4d-virtualiz.com
https://sourceware.org/bugzilla/show_bug.cgi?id=31895

--- Comment #6 from Corentin Silva Pereira 
 ---
Created attachment 15587
  --> https://sourceware.org/bugzilla/attachment.cgi?id=15587&action=edit
Zip archive containing pngs of GDB view

Hi, I continued my investigation and i stumbled on something, i don't know if
it will help or even if it's related but here :

Program received signal SIGILL, Illegal instruction.
elf_link_add_object_symbols (abfd=0x5a3c3050, info=0x5580e1e0
) at elflink.c:4408
4408  old_ent = (char *) old_ent + htab->root.table.entsize;
(gdb) bt
#0  elf_link_add_object_symbols (abfd=0x5a3c3050, info=0x5580e1e0
) at elflink.c:4408
#1  0x55600650 in bfd_elf_link_add_symbols (abfd=0x5a3c3050,
info=0x5580e1e0 ) at elflink.c:5817
#2  0x5559c484 in load_symbols (place=,
entry=0x5581a9a0) at ldlang.c:3098
#3  load_symbols (entry=0x5581a9a0, place=) at ldlang.c:2959
#4  0x5559cebf in open_input_bfds (s=0x5581a9a0,
mode=mode@entry=OPEN_BFD_NORMAL) at ldlang.c:3568
#5  0x5559f518 in lang_process () at ldlang.c:7649
#6  0x555a32a7 in main (argc=225, argv=0x7fff9458) at
./ldmain.c:444
(gdb) print old_ent
$1 = (void *) 0x5ab589f8
(gdb) print *old_ent
Attempt to dereference a generic pointer.
(gdb) print &old_ent
$2 = (void **) 0x7fff8e50
(gdb) print old_ent
$3 = (void *) 0x5ab589f8
(gdb) print htab
$4 = (struct elf_link_hash_table *) 0x558303e0
(gdb) print htab->root
$5 = {table = {table = 0x5a4ceaa0, newfunc = 0x555d9030
<_bfd_x86_elf_link_hash_newfunc>, memory = 0x55830c10, size = 131071, count
= 75995, entsize = 176, frozen = 0}, undefs = 0x55830fb0, 
  undefs_tail = 0x5a30ed20, hash_table_free = 0x555d9180
, type = bfd_link_elf_hash_table}
(gdb) print (char*)old_ent
$6 = 0x5ab589f8 ""
(gdb) print *htab
$7 = {root = {table = {table = 0x5a4ceaa0, newfunc = 0x555d9030
<_bfd_x86_elf_link_hash_newfunc>, memory = 0x55830c10, size = 131071, count
= 75995, entsize = 176, frozen = 0}, 
undefs = 0x55830fb0, undefs_tail = 0x5a30ed20, hash_table_free =
0x555d9180 , type = bfd_link_elf_hash_table},
hash_table_id = X86_64_ELF_DATA, 
  dynamic_sections_created = 1, dynamic_relocs = 0, is_relocatable_executable =
0, dynobj = 0x5583fb30, init_got_refcount = {refcount = 0, offset = 0,
glist = 0x0, plist = 0x0}, init_plt_refcount = {
refcount = 0, offset = 0, glist = 0x0, plist = 0x0}, init_got_offset =
{refcount = -1, offset = 18446744073709551615, glist = 0x,
plist = 0x}, init_plt_offset = {
refcount = -1, offset = 18446744073709551615, glist = 0x,
plist = 0x}, dynsymcount = 7643, local_dynsymcount = 0, dynstr
= 0x55840ea0, strtabcount = 0, strtabsize = 0, 
  strtab = 0x0, bucketcount = 0, needed = 0x58a7ba80, text_index_section =
0x0, data_index_section = 0x0, hgot = 0x55830cf0, hplt = 0x0, hdynamic =
0x55830c40, merge_info = 0x0, stab_info = {
strings = 0x0, includes = {table = 0x0, newfunc = 0x0, memory = 0x0, size =
0, count = 0, entsize = 0, frozen = 0}, stabstr = 0x0}, eh_info = {hdr_sec =
0x0, array_count = 0, frame_hdr_is_compact = 0, u = {
  dwarf = {cies = 0x0, fde_count = 0, table = 0, array = 0x0}, compact =
{allocated_entries = 0, entries = 0x0}}}, dynlocal = 0x0, runpath =
0x58ae8078, tls_sec = 0x0, tls_size = 0, 
  loaded = 0x5a2ffce0, sgot = 0x558564f8, sgotplt = 0x55856628,
srelgot = 0x558563c8, splt = 0x55856168, srelplt = 0x55856298,
sdynbss = 0x55856758, srelbss = 0x0, 
  sdynrelro = 0x55856888, sreldynrelro = 0x0, igotplt = 0x0, iplt = 0x0,
irelplt = 0x0, irelifunc = 0x0, dynsym = 0x55842ac8}
(gdb) print htab->root.table.entsize
$8 = 176
(gdb) print p
$9 = (struct bfd_hash_entry *) 0x56ed7e00
(gdb) print *p
$10 = {next = 0x0, string = 0x56ef175e
"_ZN20Ui_TrajListParameter7setupUiEP7QWidget", hash = 883041719}
(gdb) print i
$11 = 16392
(gdb) print htab->root.table.size
$12 = 131071



I tried what Nick said about the fprintf, and the segfault didn't appear for
now, so quite a bit tricky to go on on this one but while i was re-testing
without fprintfs and within GDB, i had a sigill. In attachement there are some
screenshots of my gdb with assembly and registers layouts, maybe it will be
useful. My coworker and i, we suppose it should be working based on the
assembly, register and memory state so we don't really understand. We're kinda
guessing it could be the hardware, like a power outage that damaged my RAM or
something, but again, we're not sure.

Intel® Core™ i9-14900KF × 32
NVIDIA GeForce RTX 4070 SUPER
Corsair Vengeance DDR5(i think) 5600MHz 4*16Go RAM 


I'm gonna try with another version (more recent) of binutils to see if the
problem occurs too.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/31895] LD segfault in libbfd with --as-needed

2024-07-25 Thread corentin.silvapere...@4d-virtualiz.com
https://sourceware.org/bugzilla/show_bug.cgi?id=31895

--- Comment #8 from Corentin Silva Pereira 
 ---
Good afternoon, i know it's been quite a long time but i just wanted to say
thanks for your patience and answers, it's been really helpful ! We manage to
isolate the problem and it was indeed the CPU, the store tech, my colleague and
i are pretty sure the problem is linked to the problems the 13th and 14th
generation of Intel processors has. Now i don't have any more problems. Thanks
for everything, this topic can be closed (i don't know if i can do it and how).

-- 
You are receiving this mail because:
You are on the CC list for the bug.