python / python/cpython

`configure` mishandles the default and `--disable-*` forms of the safety options

Đang mở
#156,764 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 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 report

Bug description:
Summary

configure.ac mishandles the safety and slower-safety configure options.

  • A default configure invocation reports safety as disabled, although the safety options are intended to be enabled by default.
  • --disable-safety enables the safety options instead of disabling them.
  • --disable-slower-safety enables the slower safety options instead of disabling them.

The latter two cases are not only incorrect status messages: configure actually enters the corresponding enabled branches and probes the associated compiler options.

Reproduction

Using an out-of-tree build directory:

mkdir build
cd build
Default configuration
../configure

Observed:

checking for --enable-safety... no
checking for --enable-slower-safety... no
Disable safety
../configure --disable-safety

Observed:

checking for --enable-safety... yes
checking whether C compiler accepts -fstack-protector-strong... yes
checking whether C compiler accepts -Wtrampolines... yes
checking whether C compiler accepts -Wimplicit-fallthrough... yes
checking whether C compiler accepts -Werror=format-security... yes
checking whether C compiler accepts -Wbidi-chars=any... yes
checking whether C compiler accepts -Wall... yes
checking for --enable-slower-safety... no
Disable slower safety
../configure --disable-slower-safety

Observed:

checking for --enable-safety... no
checking for --enable-slower-safety... yes
checking whether C compiler accepts -D_FORTIFY_SOURCE=3... yes
Actual Behavior

The resulting behavior is:

Configure invocation safety slower-safety
../configure no no
../configure --disable-safety yes no
../configure --disable-slower-safety no yes

In particular, the two --disable-* forms enable the options they are intended to disable.

Expected Behavior

The expected behavior is:

Configure invocation safety slower-safety
../configure yes no
../configure --enable-safety yes no
../configure --disable-safety no no
../configure --enable-slower-safety default value for safety yes
../configure --disable-slower-safety default value for safety no

In particular:

  • safety should remain enabled by default unless explicitly disabled.
  • --disable-safety should set enable_safety=no and should not execute the safety compiler-option checks.
  • --disable-slower-safety should set enable_slower_safety=no and should not execute the slower-safety compiler-option checks.
Cause

The affected declarations are in configure.ac in the AC_ARG_ENABLE([safety], ...) and AC_ARG_ENABLE([slower-safety], ...) blocks.

Their action-if-given branches currently test variables named disable_safety and disable_slower_safety.

For an AC_ARG_ENABLE option, Autoconf represents both forms through the corresponding enable option value:

--enable-safety   -> enableval=yes
--disable-safety  -> enableval=no

Likewise for slower-safety.

The current action blocks do not use that value. Instead, because disable_safety / disable_slower_safety are not the variables carrying the Autoconf option state, the fallback branch selects the enabled state whenever either option is explicitly present.

This causes:

--disable-safety
    -> action-if-given runs
    -> disable_safety is not "yes"
    -> enable_safety=yes

and similarly:

--disable-slower-safety
    -> enable_slower_safety=yes

There is also a separate default-value issue in the safety declaration: its action-if-not-given branch currently selects enable_safety=no, despite the option being intended to be enabled by default.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs
  • gh-156767

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 khối AC_ARG_ENABLE([safety], ...) và AC_ARG_ENABLE([slower-safety], ...), sau đó tái hiện ba invocation được liệt kê từ một thư mục build ngoài cây. So sánh status được tạo ra và các kiểm tra tùy chọn trình biên dịch với bảng mong đợi; được xem là hoàn tất khi các dạng enable/disable mặc định và tường minh chọn đúng các trạng thái được ghi lại mà không có probe không mong muốn.

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

Đánh giá

Công nghệ
shell
Lĩnh vực
build-system
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
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.