-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BOLT] Assertion '__n < this->size()' failed
during addDebugFilenameToUnit
in CPython
#121554
Comments
Note there's a warning in CPython as reported in python/cpython#128437 — I resolved it with the following patch but the failure was not affected. diff --git a/configure b/configure
index ae70f02f70e..d3ef63d9575 100755
--- a/configure
+++ b/configure
@@ -9330,7 +9330,7 @@ fi
printf %s "checking BOLT_INSTRUMENT_FLAGS... " >&6; }
if test -z "${BOLT_INSTRUMENT_FLAGS}"
then
- BOLT_INSTRUMENT_FLAGS=
+ BOLT_INSTRUMENT_FLAGS="-update-debug-sections"
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $BOLT_INSTRUMENT_FLAGS" >&5
printf "%s\n" "$BOLT_INSTRUMENT_FLAGS" >&6; }
diff --git a/configure.ac b/configure.ac
index a764028e49f..9f4ca14b1dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2221,7 +2221,7 @@ AC_ARG_VAR(
AC_MSG_CHECKING([BOLT_INSTRUMENT_FLAGS])
if test -z "${BOLT_INSTRUMENT_FLAGS}"
then
- BOLT_INSTRUMENT_FLAGS=
+ BOLT_INSTRUMENT_FLAGS="-update-debug-sections"
fi
AC_MSG_RESULT([$BOLT_INSTRUMENT_FLAGS]) |
It's better if you can provide a docker image. |
Yep! Here's the Docker reproduction (forgive that it's a little messy — it's slow to iterate on) FROM archlinux:base-devel-20241229.0.293060
RUN rm -fr /etc/pacman.d/gnupg \
&& pacman-key --init \
&& pacman-key --populate archlinux \
&& pacman -Syyu --noconfirm archlinux-keyring
# Install build dependencies
RUN pacman -Sy --needed --noconfirm \
git \
gcc-libs \
ncurses \
zlib \
zstd \
clang \
cmake \
llvm \
llvm-libs \
ninja \
python
# Build llvm-bolt
ADD https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.6/llvm-project-19.1.6.src.tar.xz .
RUN tar -xf llvm-project-19.1.6.src.tar.xz \
&& cd llvm-project-19.1.6.src \
&& cmake \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DLLVM_INSTALL_UTILS=ON \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DBUILD_SHARED_LIBS=OFF \
-DLLVM_LINK_LLVM_DYLIB=OFF \
-DLLVM_EXTERNAL_LIT=/usr/bin/lit \
-DLLVM_ENABLE_PROJECTS="bolt" \
-DLLVM_TARGETS_TO_BUILD="X86;AArch64" \
llvm \
&& ninja bolt
RUN cd llvm-project-19.1.6.src && ninja install-bolt
# Download CPython
RUN git clone https://github.com/python/cpython
WORKDIR /cpython
RUN git checkout v3.13.1
ENV CC=clang
ENV CXX=clang++
# Build CPython
RUN ./configure py_cv_module__openssl=n/a py_cv_module__hashlib=n/a py_cv_module__gdbm=n/a py_cv_module__tkinter=n/a \
--without-ensurepip \
--enable-optimizations --enable-bolt
RUN make -j8 Note, the stacktrace is a little different
|
By the way, you are on X86? |
Here's my system information
|
Thank you, I will work on this now. |
I also reproduced this on the latest CPython 3.14 commit: python/cpython@4c14f03 |
yeah, I can reproduce, I am now working on it. |
👍 sweet. Just letting you know in case it helps narrow things down. I also produced the segfault on
I can workaround this with the relatively obvious patch diff --git a/configure b/configure
index aa88c74c611..0fcd10b61cb 100755
--- a/configure
+++ b/configure
@@ -9403,7 +9403,7 @@ printf "%s\n" "$BOLT_INSTRUMENT_FLAGS" >&6; }
printf %s "checking BOLT_APPLY_FLAGS... " >&6; }
if test -z "${BOLT_APPLY_FLAGS}"
then
- BOLT_APPLY_FLAGS=" -update-debug-sections -reorder-blocks=ext-tsp -reorder-functions=cdsort -split-functions -icf=1 -inline-all -split-eh -reorder-functions-use-hot-size -peepholes=none -jump-tables=aggressive -inline-ap -indirect-call-promotion=all -dyno-stats -use-gnu-stack -frame-opt=hot "
+ BOLT_APPLY_FLAGS=" -reorder-blocks=ext-tsp -reorder-functions=cdsort -split-functions -icf=1 -inline-all -split-eh -reorder-functions-use-hot-size -peepholes=none -jump-tables=aggressive -inline-ap -indirect-call-promotion=all -dyno-stats -use-gnu-stack -frame-opt=hot "
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $BOLT_APPLY_FLAGS" >&5
diff --git a/configure.ac b/configure.ac
index 9e131ed1a2d..72f1d5d91fb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2181,7 +2181,6 @@ then
AS_VAR_SET(
[BOLT_APPLY_FLAGS],
[m4_normalize("
- -update-debug-sections
-reorder-blocks=ext-tsp
-reorder-functions=cdsort
-split-functions |
The error is related to Dwarf. I am not sure what causes this, I guess dwarf type mismatch. I will try to fix it. |
Similar to #121213 but with a different trace
This assertion crashes BOLT during a CPython build. I'm using the 3.13.1 tag for reproducibility.
My usage looks like
I'll try to create a reproduction in a Dockerfile, if that'd be helpful.
I'm using LLVM 19.1.6 on an x86_64 Arch Linux host
Here's the stacktrace
Additional logs
The text was updated successfully, but these errors were encountered: