https://sourceware.org/bugzilla/show_bug.cgi?id=32260
Bug ID: 32260 Summary: regression: /bin/ld: BFD (GNU Binutils for Debian) 2.43.1 assertion fail ../../bfd/merge.c:247 Product: binutils Version: 2.43.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: jonny.weir at clearpool dot io Target Milestone: --- Hi, Just to note, this may be related to the following bug I raised previously that was fixed: https://sourceware.org/bugzilla/show_bug.cgi?id=31009 To summarize: I am building a large scale C++23 project now using gcc14 in Debian Linux (sid). I have two build environments, one that uses binutils 2.42.90.20240720-2 (Debian package) and another that uses binutils 2.43.1-3, also a Debian package. One build environment is running slightly behind the other, for obvious reasons :-). Aside from the binutils difference, the build environments are identical. I have been successfully building this project using the 2.42 version of binutils, however I believe another regression has been introduced in the 2.43.1 version (possibly all 2.43 versions have this issue). Where I see the failure is as follows using the 2.43.1 version: g++-14 -o main.o -c -std=c++2b -fexceptions -fconcepts -fcoroutines -flto=auto -Wall -g -O3 main.cpp g++-14 -o output -flto=auto -rdynamic -Wl,-rpath=. <object_files> -Xlinker -Bstatic -lpthread -lrt -lcurl -lssl -lcrypto If I compile using -O2 everything compiles and links correctly, but when -O3 is used, the following output is produced during the linking phase: /bin/ld: BFD (GNU Binutils for Debian) 2.43.1 assertion fail ../../bfd/merge.c:247 /bin/ld: BFD (GNU Binutils for Debian) 2.43.1 assertion fail ../../bfd/merge.c:247 /bin/ld: BFD (GNU Binutils for Debian) 2.43.1 assertion fail ../../bfd/merge.c:247 ... etc ... This is repeated thousands of times, as before. As per the suggetions in the previous ticket, I have added some printf logging above line 247 in bfd/merge.c: printf( "XXX bfdtab->count=%u table->nbuckets=%u\n", bfdtab->count, table->nbuckets ); BFD_ASSERT (!NEEDS_RESIZE (bfdtab->count + 1, table->nbuckets)); to try and work out what is happening, but I haven't been able to determine why nbuckets goes to 0. The output from the build is as follows (duplicate lines have been removed): XXX bfdtab->count=0 table->nbuckets=8192 XXX bfdtab->count=1 table->nbuckets=8192 ... XXX bfdtab->count=125 table->nbuckets=8192 XXX bfdtab->count=126 table->nbuckets=32768 XXX bfdtab->count=127 table->nbuckets=32768 ... XXX bfdtab->count=488 table->nbuckets=32768 XXX bfdtab->count=489 table->nbuckets=65536 XXX bfdtab->count=490 table->nbuckets=65536 ... XXX bfdtab->count=778 table->nbuckets=65536 XXX bfdtab->count=779 table->nbuckets=262144 XXX bfdtab->count=780 table->nbuckets=262144 XXX bfdtab->count=781 table->nbuckets=262144 ... XXX bfdtab->count=1406 table->nbuckets=262144 XXX bfdtab->count=1407 table->nbuckets=524288 XXX bfdtab->count=1408 table->nbuckets=524288 ... XXX bfdtab->count=1751 table->nbuckets=524288 XXX bfdtab->count=1752 table->nbuckets=0 XXX bfdtab->count=1753 table->nbuckets=0 XXX bfdtab->count=1754 table->nbuckets=0 XXX bfdtab->count=1771 table->nbuckets=0 /bin/ld: BFD (GNU Binutils) 2.43.1.20241010 assertion fail merge.c:248 /bin/ld: BFD (GNU Binutils) 2.43.1.20241010 assertion fail merge.c:248 /bin/ld: BFD (GNU Binutils) 2.43.1.20241010 assertion fail merge.c:248 /bin/ld: BFD (GNU Binutils) 2.43.1.20241010 assertion fail merge.c:248 XXX bfdtab->count=1772 table->nbuckets=0 /bin/ld: BFD (GNU Binutils) 2.43.1.20241010 assertion fail merge.c:248 /bin/ld: BFD (GNU Binutils) 2.43.1.20241010 assertion fail merge.c:248 /bin/ld: BFD (GNU Binutils) 2.43.1.20241010 assertion fail merge.c:248 /bin/ld: BFD (GNU Binutils) 2.43.1.20241010 assertion fail merge.c:248 ... XXX bfdtab->count=871457 table->nbuckets=0 XXX bfdtab->count=871458 table->nbuckets=0 /bin/ld: BFD (GNU Binutils) 2.43.1.20241010 assertion fail merge.c:248 /bin/ld: BFD (GNU Binutils) 2.43.1.20241010 assertion fail merge.c:248 /bin/ld: /tmp/cc0M4ieT.ltrans0.ltrans.o: access beyond end of merged section (20) /bin/ld: /tmp/cc0M4ieT.ltrans0.ltrans.o: access beyond end of merged section (33) /bin/ld: /tmp/cc0M4ieT.ltrans0.ltrans.o: access beyond end of merged section (41) /bin/ld: /tmp/cc0M4ieT.ltrans0.ltrans.o: access beyond end of merged section (48) ... /bin/ld: final link failed collect2: error: ld returned 1 exit status The total number of lines output is around 860,000 (this count excludes my additional debug logging). Note the version change, I have built this locally from source from the binutils-2_43-branch so that I could edit the merge.c file and reproduce this with the logging. Finally, during this linking stage, the memory usage for binutils 2.42 was around 30G for the /bin/ld process. With 2.43.1 the memory usage has increased dramatically to around 71G. This seems very excessive and I am wondering if this might help track down the issue with this. Perhaps some new code that was added around memory reallocation in the 2.43 code. If you require any more clarity or want me to run the build again with any more logging / code changes, I am willing to do so. Thanks, Jonny -- You are receiving this mail because: You are on the CC list for the bug.