python / python/cpython

OpenSSL configure API checks use the wrong library order for dependencies in LIBS

Đang mở
#157,755 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

build topic-SSL type-bug
Ngôn ngữ chính
Python
Star
77.2k
Fork
35.9k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

Bug description:

The OpenSSL API checks in configure.ac put LIBS before OPENSSL_LIBS and LIBCRYPTO_LIBS. When static OpenSSL depends on a library supplied through LIBS, the linker can encounter the dependency before the archive that references it. The API checks then fail and _ssl / _hashlib are marked as missing.

This is inconsistent with the initial AX_CHECK_OPENSSL link check, which already puts OPENSSL_LIBS before LIBS and succeeds with the same inputs.

Reproduction

Use a static OpenSSL build with zlib enabled (Configure linux-x86_64 no-shared no-tests zlib, with the zlib include/library paths supplied), and a static zlib archive. From an empty CPython build directory:

# Set these to the installed libraries and CPython source tree.
openssl_prefix=/path/to/openssl-zlib
openssl_libdir="$openssl_prefix/lib64"
zlib_archive=/path/to/libz.a
cpython_source=/path/to/cpython

PKG_CONFIG=/bin/false \
LDFLAGS="-L$openssl_libdir" \
LIBS="$zlib_archive" \
"$cpython_source/configure" \
    --with-openssl="$openssl_prefix" \
    --without-ensurepip

Use lib instead of lib64 if appropriate for the OpenSSL installation. Disabling pkg-config here exercises manually supplied dependency flags rather than having pkg-config supply the transitive libraries.

Actual result:

checking whether compiling and linking against OpenSSL works... yes
checking whether OpenSSL provides required ssl module APIs... no
checking whether OpenSSL provides required hashlib module APIs... no
checking for stdlib extension module _ssl... missing
checking for stdlib extension module _hashlib... missing

The failing SSL probe links in this order (paths abbreviated):

gcc ... conftest.c -ldl /path/to/libz.a -lssl -lcrypto
libcrypto.a(libcrypto-lib-c_zlib.o): undefined reference to `inflate'
libcrypto.a(libcrypto-lib-c_zlib.o): undefined reference to `deflate'

Expected: both API checks succeed. Moving the OpenSSL libraries before LIBS fixes both checks with otherwise identical inputs:

-  LIBS="$LIBS $OPENSSL_LIBS"
+  LIBS="$OPENSSL_LIBS $LIBS"

-  LIBS="$LIBS $LIBCRYPTO_LIBS"
+  LIBS="$LIBCRYPTO_LIBS $LIBS"

After regenerating configure with Autoconf 2.72, both API checks and both module configuration results become yes. The unmodified source also passes with ordinary static OpenSSL built without zlib, so this is specific to dependency ordering, not all static OpenSSL configurations.

CPython versions tested on:

CPython main branch, 3.13.15

Operating systems tested on:

main branch on Linux (WSL Ubuntu), 3.13.15 on all vcpkg ci https://github.com/microsoft/vcpkg/pull/53840

Linked PRs
  • gh-157756

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu trong configure.ac tại các kiểm tra OpenSSL API và so sánh thứ tự thư viện của chúng với kiểm tra liên kết AX_CHECK_OPENSSL ban đầu. Tái hiện lệnh configure cho OpenSSL tĩnh với zlib, tạo lại configure bằng Autoconf 2.72 và xác minh rằng cả các kiểm tra API lẫn các kiểm tra mô-đun _ssl và _hashlib đều báo thành công.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
c, python
Lĩnh vực
build-system
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
Nửa ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.