Skip to content

Ilp32 and ilp64 can't coexist in same process #5934

Description

@jcarreira

Hi, I am trying to use an ilp64 build of OpenBlas alongside an ilp32. The ilp64 build is being built with SYMBOLSUFFIX=64_ to keep the names separate.

Turns out not all the names are modified with a suffix which leads to the ilp32 library calling an internal function in the ilp64 library. This can cause wrong memory accesses due to the 32/64 bit difference. Perhaps internal names (e.g., dsdot_k) should not be public in the build .so?

Here is a Dockerfile that shows the crash happening when linking against both ilp32+ilp64-with-suffixes.

FROM debian:bookworm

ARG OPENBLAS_REF=v0.3.33
ARG MAKE_JOBS=4

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
      ca-certificates curl file g++ gfortran make binutils perl xz-utils && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /src

RUN curl -fsSL "https://github.com/OpenMathLib/OpenBLAS/archive/refs/tags/${OPENBLAS_REF}.tar.gz" \
      -o openblas.tar.gz && \
    mkdir openblas-ilp32 openblas-ilp64 && \
    tar -xzf openblas.tar.gz -C openblas-ilp32 --strip-components=1 && \
    tar -xzf openblas.tar.gz -C openblas-ilp64 --strip-components=1 && \
    rm openblas.tar.gz

RUN make -C /src/openblas-ilp32 -j"${MAKE_JOBS}" \
      USE_THREAD=0 NO_LAPACKE=1 && \
    make -C /src/openblas-ilp32 install \
      PREFIX=/opt/openblas-ilp32 USE_THREAD=0 NO_LAPACKE=1 && \
    make -C /src/openblas-ilp64 -j"${MAKE_JOBS}" \
      USE_THREAD=0 NO_LAPACKE=1 INTERFACE64=1 SYMBOLSUFFIX=64_ LIBNAMESUFFIX=cpp && \
    make -C /src/openblas-ilp64 install \
      PREFIX=/opt/openblas-ilp64 USE_THREAD=0 NO_LAPACKE=1 \
      INTERFACE64=1 SYMBOLSUFFIX=64_ LIBNAMESUFFIX=cpp && \
    rm -rf /src/openblas-ilp32 /src/openblas-ilp64

COPY link_time_reproducer.cpp /src/link_time_reproducer.cpp
COPY docker_run_reproducer.sh /usr/local/bin/docker_run_reproducer

RUN g++ -O0 -g -Wall -Wextra -std=c++17 \
      -o /usr/local/bin/link_time_reproducer /src/link_time_reproducer.cpp \
      -Wl,-rpath,/opt/openblas-ilp64/lib \
      -Wl,-rpath,/opt/openblas-ilp32/lib \
      -Wl,--no-as-needed \
      /opt/openblas-ilp64/lib/libopenblas64_cpp.so \
      /opt/openblas-ilp32/lib/libopenblas.so \
      -ldl && \
    chmod +x /usr/local/bin/docker_run_reproducer

CMD ["/usr/local/bin/docker_run_reproducer"]

docker_run_reproducer.sh

link_time_reproducer.cpp

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions