Skip to content

[BOLT] Segfaults and/or miscompilations when using packed relocations with CPython #169136

@stratakis

Description

@stratakis

Hello all,

Since #120267 was merged I tried implementing a change for CPython to not skip anymore functions with computed gotos. However specific build configurations still pose problems. I've reported my findings here: python/cpython#141775

More specifically, tested on my machine x86_64 Fedora Linux 43, binutils 2.45, clang/llvm/bolt 21.1.4, gcc 15.2.1, glibc 2.42.

The broken configs:

GCC:

Shared build with packed relocs:
CC=gcc LDFLAGS="-Wl,-z,pack-relative-relocs" ./configure --enable-bolt --enable-shared && make -j

On main it passes
On main segfaults with python/cpython#140250 when not skipping computed gotos functions

Shared build with LTO and packed relocs:
CC=gcc LDFLAGS="-Wl,-z,pack-relative-relocs" ./configure --with-lto --enable-bolt --enable-shared && make -j

On main segfaults, also with python/cpython#140250

Shared build with PGO and packed relocs:
CC=gcc LDFLAGS="-Wl,-z,pack-relative-relocs" ./configure --enable-optimizations --enable-bolt --enable-shared && make -j

On main segfaults, also with python/cpython#140250

Shared build with LTO, PGO and packed relocs:
CC=gcc LDFLAGS="-Wl,-z,pack-relative-relocs" ./configure --with-lto --enable-optimizations --enable-bolt --enable-shared && make -j

On main segfaults also with python/cpython#140250

Clang:

clang builds might need enforcement of DWARF 4, already reported #121554

Shared build with packed relocs:
CC=clang CXX=clang++ CFLAGS="-gdwarf-4" LDFLAGS="-Wl,-z,pack-relative-relocs" ./configure --enable-bolt --enable-shared && make -j

On main passes
On main miscompiles the library with python/cpython#140250 (aka without skipping computed goto functions)

Shared build with LTO and packed relocs:
CC=clang CXX=clang++ CFLAGS="-gdwarf-4" LDFLAGS="-Wl,-z,pack-relative-relocs" ./configure --with-lto --enable-bolt --enable-shared && make -j

On main passes
On main segfaults with python/cpython#140250

Shared build with PGO and packed relocs:
CC=clang CXX=clang++ CFLAGS="-gdwarf-4" LDFLAGS="-Wl,-z,pack-relative-relocs" ./configure --enable-optimizations --enable-bolt --enable-shared && make -j

On main it miscompiles the library, also with python/cpython#140250

Shared build with LTO, PGO and packed relocs:
CC=clang CXX=clang++ CFLAGS="-gdwarf-4" LDFLAGS="-Wl,-z,pack-relative-relocs" ./configure --with-lto --enable-optimizations --enable-bolt --enable-shared && make -j

On main miscompiles the library, also with python/cpython#140250

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions