GCC-12.1.0-2ubuntu1~22.04 (jammy) dav1d segfaults when building with -flto=auto

Bug #1988079 reported by Ferdi
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc-12 (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

When building Dav1d with GCC 12.1.0 from the Ubuntu-toolchain-r ppa the resulting binary always segfaults when the -flto=auto flag is set.

Without the -flto=auto flag the resulting binary works as intended.

When using GCC 12.1.0 with -flto=auto in other distributions (debian for example) the resulting binary works fine.

The issue was first reported here: https://code.videolan.org/videolan/dav1d/-/issues/402 as it was perceived by me as an error in their code, but they could only reproduce this on ubuntu systems and not on other distributions.

The Meson build system
Version: 0.62.2
Source dir: /home/ferdi/ffmpeg_sources/dav1d
Build dir: /home/ferdi/ffmpeg_sources/dav1d/build
Build type: native build
Project name: dav1d
Project version: 1.0.0
C compiler for the host machine: ccache cc (gcc 12.1.0 "cc (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0")
C linker for the host machine: cc ld.bfd 2.38
Host machine cpu family: x86_64
Host machine cpu: x86_64
Fetching value of define "__ILP32__" :
Run-time dependency threads found: YES
Checking for function "clock_gettime" : YES
Library dl found: YES
Checking for function "dlsym" with dependency -ldl: YES
Library m found: YES
Check usable header "stdatomic.h" : YES
Check usable header "unistd.h" : YES
Check usable header "io.h" : NO
Check usable header "pthread_np.h" : NO
Checking for function "getopt_long" : YES
Checking for function "_aligned_malloc" : NO
Checking for function "posix_memalign" : YES
Checking for function "pthread_getaffinity_np" with dependency threads: YES
Compiler for C supports arguments -fvisibility=hidden: YES
Compiler for C supports arguments -Wundef: YES
Compiler for C supports arguments -Werror=vla: YES
Compiler for C supports arguments -Wno-maybe-uninitialized: YES
Compiler for C supports arguments -Wno-missing-field-initializers: YES
Compiler for C supports arguments -Wno-unused-parameter: YES
Compiler for C supports arguments -Wstrict-prototypes: YES
Compiler for C supports arguments -Werror=missing-prototypes: YES
Compiler for C supports arguments -Wshorten-64-to-32: NO
Compiler for C supports arguments -fomit-frame-pointer: YES
Compiler for C supports arguments -ffast-math: YES
Compiler for C supports arguments -mpreferred-stack-boundary=6: YES
Fetching value of define "__AVX__" : 1
Program nasm found: YES (/home/ferdi/bin/nasm)
Configuring config.asm using configuration
Configuring config.h using configuration
Configuring version.h using configuration
Header <xxhash.h> has symbol "XXH3_createState" : YES
Configuring cli_config.h using configuration
Build targets in project: 10

dav1d 1.0.0

  User defined options
    default_library: static
    libdir : /home/ferdi/ffmpeg_build/lib
    prefix : /home/ferdi/ffmpeg_build
    enable_tests : false
    enable_tools : true

Found ninja-1.11.0 at /usr/bin/ninja
ferdi@Biodanza01:~/ffmpeg_sources/dav1d/build$ env | grep FLAGS
CXXFLAGS=-march=native -O3 -pipe -flto=auto
LDFLAGS=-fuse-ld=mold
CFLAGS=-march=native -O3 -pipe -flto=auto
ferdi@Biodanza01:~/ffmpeg_sources/dav1d/build$ ninja
[111/111] Linking target tools/dav1d
ferdi@Biodanza01:~/ffmpeg_sources/dav1d/build$ cd tools
ferdi@Biodanza01:~/ffmpeg_sources/dav1d/build/tools$ ./dav1d -i ~/Downloads/video/testvideo/test1.ivf --l 100 -o test.yuv
dav1d 1.0.0-46-gcd5e415 - by VideoLAN
Segmentation fault

Ferdi (ferdi-sttc-nlp)
summary: - GCC-12.1.0-2ubuntu1~22.04 (jammy) dav1d problem when building with
+ GCC-12.1.0-2ubuntu1~22.04 (jammy) dav1d segfaults when building with
-flto=auto
Revision history for this message
Michael Catanzaro (mike-catanzaro) wrote :

This bug is not specific to Ubuntu. We can reproduce it with freedesktop-sdk's gcc 12.1.0, see https://bugs.webkit.org/show_bug.cgi?id=250477. It seems building with LTO changes the stack alignment.

Revision history for this message
Ferdi (ferdi-sttc-nlp) wrote :

Since GCC got updated to 12.2.0 in the toolchain-r ppa, the segfaults no longer occur when building dav1d with LTO enabled.

Matthias Klose (doko)
Changed in gcc-12 (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.