Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 843371 - sys-devel/binutils: ld segfault on linking dev-libs/wayland-protocols-1.25 on loong (in tests/test-build-pedantic-unstable_xdg_decoration_xdg_decoration_unstable_v1_xml)
Summary: sys-devel/binutils: ld segfault on linking dev-libs/wayland-protocols-1.25 on...
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: Loong Linux
: Normal normal
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-09 00:20 UTC by WANG Xuerui
Modified: 2022-10-14 08:51 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (build.log,123.25 KB, text/plain)
2022-05-09 00:20 UTC, WANG Xuerui
Details
emerge --info (emerge-info.txt,9.34 KB, text/plain)
2022-05-09 00:21 UTC, WANG Xuerui
Details
environment (environment,89.17 KB, text/plain)
2022-05-09 00:21 UTC, WANG Xuerui
Details
minimized reproducing example (bug843371-minimized.tar.xz,2.63 KB, application/octet-stream)
2022-05-09 00:50 UTC, WANG Xuerui
Details

Note You need to log in before you can comment on or make changes to this bug.
Description WANG Xuerui gentoo-dev 2022-05-09 00:20:30 UTC
Created attachment 777629 [details]
build.log

FAILED: tests/test-build-pedantic-unstable_xdg_decoration_xdg_decoration_unstable_v1_xml
loongarch64-unknown-linux-gnu-gcc  -o tests/test-build-pedantic-unstable_xdg_decoration_xdg_decoration_unstable_v1_xml tests/test-build-pedantic-unstable_xdg_decoration_xdg_decoration_unstable_v1_xml.p/meson-generated_.._test-build-pedantic-unstable_xdg_decoration_xdg_decoration_unstable_v1_xml.c.o tests/test-build-pedantic-unstable_xdg_decoration_xdg_decoration_unstable_v1_xml.p/meson-generated_.._xdg-decoration-unstable-v1-code.c.o -Wl,--as-needed -Wl,--no-undefined -O2 -pipe -ggdb -Wl,-O1 -Wl,--as-needed -Wl,--unresolved-symbols=ignore-all -Wl,--start-group -lwayland-client -lwayland-server -Wl,--end-group
/usr/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/../../../../loongarch64-unknown-linux-gnu/bin/ld: BFD (Gentoo 2.38 p4) 2.38 assertion fail elfnn-loongarch.c:2055
collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped
compilation terminated.

[ebuild  N     ] dev-libs/wayland-protocols-1.25::gentoo  USE="test" 0 KiB

Portage 3.0.30 (python 3.9.12-final-0, !/home/xenon/src/gentoo/profiles/default/linux/loong/22.0/la64v100/lp64d/systemd, gcc-12.1.0, glibc-2.35-r4, 5.17.0-rc6-00063-gceb10fb62d28 loongarch64)
=================================================================
System uname: Linux-5.17.0-rc6-00063-gceb10fb62d28-loongarch64-with-glibc2.35
KiB Mem:    33269168 total,  10714992 free
KiB Swap:   33554416 total,  33461232 free
Timestamp of repository gentoo: Sun, 08 May 2022 21:15:01 +0000
Head commit of repository gentoo: 758a5f0dcbd5ff618e8733066603a05548583299
sh bash 5.1_p16
ld GNU ld (Gentoo 2.38 p4) 2.38
app-misc/pax-utils:        1.3.4::gentoo
app-shells/bash:           5.1_p16::gentoo
dev-lang/perl:             5.34.1-r3::gentoo
dev-lang/python:           3.9.12::gentoo, 3.10.4::gentoo, 3.11.0_beta1::gentoo
dev-util/cmake:            3.23.1::gentoo
dev-util/meson:            0.61.4-r2::gentoo
sys-apps/baselayout:       2.8::gentoo
sys-apps/sandbox:          2.29::gentoo
sys-apps/systemd:          250.5-r1::gentoo
sys-devel/autoconf:        2.71-r1::gentoo
sys-devel/automake:        1.16.5::gentoo
sys-devel/binutils:        2.38-r2::gentoo
sys-devel/binutils-config: 5.4.1::gentoo
sys-devel/gcc:             12.1.0::gentoo
sys-devel/gcc-config:      2.5-r1::gentoo
sys-devel/libtool:         2.4.7::gentoo
sys-devel/make:            4.3::gentoo
sys-kernel/linux-headers:  5.17-r1::gentoo (virtual/os-headers)
sys-libs/glibc:            2.35-r4::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://mirrors.tuna.tsinghua.edu.cn/gentoo-portage/
    priority: -1000
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-max-age: 24
    sync-rsync-extra-opts: 
    sync-rsync-verify-metamanifest: yes

loongson
    location: /var/gentoo/repos/loongson-overlay
    masters: gentoo
    priority: 50
Comment 1 WANG Xuerui gentoo-dev 2022-05-09 00:21:25 UTC
Created attachment 777632 [details]
emerge --info
Comment 2 WANG Xuerui gentoo-dev 2022-05-09 00:21:57 UTC
Created attachment 777635 [details]
environment
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-05-09 00:36:56 UTC
Oh, I guess there's two bugs here then. Binutils should error out properly but UB in protos?
Comment 4 WANG Xuerui gentoo-dev 2022-05-09 00:38:34 UTC
Offending assertion in bfd/elfnn-loongarch.c, inside loongarch_elf_relocate_section:

> BFD_ASSERT (!resolved_dynly || (h && h->dynindx != -1));

According to the upstream issue about the "linker error", it's delibrately specified to ignore unresolved symbols for the test, and the problem goes away if one removes the -Wl,--unresolved-symbols=ignore-all switch.

> $ gcc foo.o foo-code.o -Wl,--unresolved-symbols=ignore-all
> /usr/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/../../../../loongarch64-unknown-linux-gnu/bin/ld: BFD (Gentoo 2.38 p4) 2.38 assertion fail elfnn-loongarch.c:2055
> collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped
> compilation terminated.
> 
> $ gcc foo.o foo-code.o 
> /usr/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/../../../../loongarch64-unknown-linux-gnu/bin/ld: foo-code.o:(.data.rel+0x10): undefined reference to `xdg_toplevel_interface'
> collect2: error: ld returned 1 exit status

So it's solely binutils' fault after all.
Comment 5 WANG Xuerui gentoo-dev 2022-05-09 00:50:00 UTC
Created attachment 777638 [details]
minimized reproducing example
Comment 6 WANG Xuerui gentoo-dev 2022-05-09 01:07:10 UTC
This seems to be already fixed in binutils master branch, I'll check which commit(s) to backport.
Comment 7 WANG Xuerui gentoo-dev 2022-05-09 01:20:44 UTC
Confirmed upstream commit 3024b63f9f022432790c2992ae3f743c4293d12e fixes the bug, but from a quick look all subsequent commits to the LoongArch backend after the 2.38 release seem good enough to carry.
Comment 8 WANG Xuerui gentoo-dev 2022-05-09 01:24:16 UTC
Sorry; pasted local cherry-picked commit hash. It should be commit d218dba3f491191322e50df74376faa11c4a9f6b.
Comment 9 WANG Xuerui gentoo-dev 2022-05-09 03:05:53 UTC
Actually the cherry-picked commit only fixes the bare ld invocation with the two object files, but not the segfault. Opened an issue on vendor bug tracker.
Comment 10 WANG Xuerui gentoo-dev 2022-05-09 03:22:57 UTC
I've packed all files for reproducing the segfault and uploaded to my devspace, due to the tarball being larger than 1M:

https://dev.gentoo.org/~xen0n/bugz/bug843371-segfault-repro.tar.xz

Untar and check "repro.sh" for seeing the segfault yourself. I tested on both loong and amd64, with all currently available upstream loong patches applied, and the segfault remains.
Comment 11 WANG Xuerui gentoo-dev 2022-10-14 08:51:10 UTC
With binutils-2.39-r3, the segfault was no more, but https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/48 shows up instead.

FAILED: tests/test-build-pedantic-unstable_xdg_decoration_xdg_decoration_unstable_v1_xml
loongarch64-unknown-linux-gnu-gcc  -o tests/test-build-pedantic-unstable_xdg_decoration_xdg_decoration_unstable_v1_xml tests/test-build-pedantic-unstable_xdg_decoration_xdg_decoration_unstable_v1_xml.p/meson-generated_.._test-build-pedantic-unstable_xdg_decoration_xdg_decoration_unstable_v1_xml.c.o tests/test-build-pedantic-unstable_xdg_decoration_xdg_decoration_unstable_v1_xml.p/meson-generated_.._xdg-decoration-unstable-v1-code.c.o -Wl,--as-needed -Wl,--no-undefined -O2 -pipe -ggdb -Wl,-O1 -Wl,--as-needed -Wl,--unresolved-symbols=ignore-all -Wl,--start-group -lwayland-client -lwayland-server -Wl,--end-group
/usr/lib/gcc/loongarch64-unknown-linux-gnu/13.0.0/../../../../loongarch64-unknown-linux-gnu/bin/ld: tests/test-build-pedantic-unstable_xdg_decoration_xdg_decoration_unstable_v1_xml.p/meson-generated_.._xdg-decoration-unstable-v1-code.c.o:(.data.rel+0x10): undefined reference to `xdg_toplevel_interface'
collect2: error: ld returned 1 exit status

Marking this bug as obsolete as the problematic version of wayland-protocols is no longer in ::gentoo. The other build failure (building with FEATURES=test) is to be tracked in another bug.