python / python/cpython

The C analyzer seems to fail when `--disable-gil` is set

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

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

topic-free-threading triaged 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:

When running the C analyzer's check-c-globals script locally, I noticed this failure on gc_free_threading.c:

$ python3.13 Tools/c-analyzer/check-c-globals.py Python/gc_free_threading.c
analyzing files...
.# requested file: </home/peter/develop/cpython/Python/gc_free_threading.c>

-------------------------

Non-constant global variables are generally not supported
in the CPython repo.  We use a tool to analyze the C code
and report if any unsupported globals are found.  The tool
may be run manually with:

  ./python Tools/c-analyzer/check-c-globals.py --format summary [FILE]

Occasionally the tool is unable to parse updated code.
If this happens then add the file to the "EXCLUDED" list
in Tools/c-analyzer/cpython/_parser.py and create a new
issue for fixing the tool (and CC ericsnowcurrently
on the issue).

If the tool reports an unsupported global variable and
it is actually const (and thus supported) then first try
fixing the declaration appropriately in the code.  If that
doesn't work then add the variable to the "should be const"
section of Tools/c-analyzer/cpython/ignored.tsv.

If the tool otherwise reports an unsupported global variable
then first try to make it non-global, possibly adding to
PyInterpreterState (for core code) or module state (for
extension modules).  In an emergency, you can add the
variable to Tools/c-analyzer/cpython/globals-to-fix.tsv
to get CI passing, but doing so should be avoided.  If
this course it taken, be sure to create an issue for
eliminating the global (and CC ericsnowcurrently).

ERROR: unmatched text (/home/peter/develop/cpython/Python/gc_free_threading.c starting at line 524):
extern int (*__Static_assert_function (void)) [!!sizeof ( struct inline-1 )] ; extern int (*__Static_assert_function (void)) [!!sizeof (struct { int __error_if_negative: ( 16 < 256 && 8 < 16 && 8 > 0 ) ? 2 : -1; })] ; typedef struct { PyObject **start; PyObject **end; } gc_span_t; typedef struct { Py_ssize_t size; Py_ssize_t capacity; gc_span_t *stack; } gc_span_stack_t; typedef struct { unsigned int in; unsigned int out; _PyObjectStack stack; gc_span_stack_t spans; PyObject *buffer[256]; _Bool ...

This only comes up when ./configure --disable-gil is used beforehand (which is a little odd, considering a release build of Python is being used, not the local compiled version), so it doesn't show up in CI.

cc @ericsnowcurrently

CPython versions tested on:

CPython main branch, 3.14

Operating systems tested on:

Linux

Linked PRs
  • gh-156969

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 với Tools/c-analyzer/check-c-globals.py và tái hiện lỗi đối với Python/gc_free_threading.c bằng lệnh trong báo cáo. Đọc hướng dẫn liên quan đến parser trong Tools/c-analyzer/cpython/_parser.py và kiểm tra PR được liên kết gh-156969. Hoàn thành khi analyzer xử lý tệp này mà không gặp lỗi unmatched-text đã báo cáo.

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
tooling
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
25/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.