python / python/cpython

Python cProfile run gets SIGSEGV due to stack overrun

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

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

extension-modules topic-profiling type-crash
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ả

Crash report

What happened?

Running python -m cProfile .... on my program results in the following crash:

Thread 0 Crashed:
0      _lsprof.cpython-310-darwin.so 	       0x104f01974 RotatingTree_Enum + 0
1      _lsprof.cpython-310-darwin.so 	       0x104f019a4 RotatingTree_Enum + 48
-------- RECURSION 1, LEVEL 349252
2      _lsprof.cpython-310-darwin.so 	       0x104f019a4 RotatingTree_Enum + 48
-------- RECURSION 1, LEVEL 349251
3      _lsprof.cpython-310-darwin.so 	       0x104f019a4 RotatingTree_Enum + 48
-------- RECURSION 1, LEVEL 349250
--------
-------- ELIDED 349246 LEVELS OF RECURSION THROUGH 0x104f019a4 RotatingTree_Enum + 48
--------
349252 _lsprof.cpython-310-darwin.so 	       0x104f019a4 RotatingTree_Enum + 48
-------- RECURSION 1, LEVEL 3
349253 _lsprof.cpython-310-darwin.so 	       0x104f019a4 RotatingTree_Enum + 48
-------- RECURSION 1, LEVEL 2
349254 _lsprof.cpython-310-darwin.so 	       0x104f019a4 RotatingTree_Enum + 48
-------- RECURSION 1, LEVEL 1
349255 _lsprof.cpython-310-darwin.so 	       0x104f00b88 _lsprof_Profiler_getstats + 148
349256 libpython3.10.dylib           	       0x105073c40 method_vectorcall_FASTCALL_KEYWORDS_METHOD + 168
349257 libpython3.10.dylib           	       0x10513ce48 call_function + 472
349258 libpython3.10.dylib           	       0x1051379b0 _PyEval_EvalFrameDefault + 7248
349259 libpython3.10.dylib           	       0x105135c5c _PyEval_Vector + 140
-------- RECURSION 2, LEVEL 10
349260 libpython3.10.dylib           	       0x10513ce48 call_function + 472
349261 libpython3.10.dylib           	       0x1051379b0 _PyEval_EvalFrameDefault + 7248
349262 libpython3.10.dylib           	       0x105135c5c _PyEval_Vector + 140
-------- RECURSION 2, LEVEL 9
349263 libpython3.10.dylib           	       0x10513ce48 call_function + 472
349264 libpython3.10.dylib           	       0x1051379b0 _PyEval_EvalFrameDefault + 7248
349265 libpython3.10.dylib           	       0x105135c5c _PyEval_Vector + 140
-------- RECURSION 2, LEVEL 8
--------
-------- ELIDED 4 LEVELS OF RECURSION THROUGH 0x105135c5c _PyEval_Vector + 140
--------
349278 libpython3.10.dylib           	       0x10513ce48 call_function + 472
349279 libpython3.10.dylib           	       0x105139880 _PyEval_EvalFrameDefault + 15136
349280 libpython3.10.dylib           	       0x105135c5c _PyEval_Vector + 140
-------- RECURSION 2, LEVEL 3
349281 libpython3.10.dylib           	       0x105135bbc PyEval_EvalCode + 108
349282 libpython3.10.dylib           	       0x105132664 builtin_exec + 720
349283 libpython3.10.dylib           	       0x1050afc04 cfunction_vectorcall_FASTCALL + 280
349284 libpython3.10.dylib           	       0x10513ce48 call_function + 472
349285 libpython3.10.dylib           	       0x105139880 _PyEval_EvalFrameDefault + 15136
349286 libpython3.10.dylib           	       0x105135c5c _PyEval_Vector + 140
-------- RECURSION 2, LEVEL 2
349287 libpython3.10.dylib           	       0x10513ce48 call_function + 472
349288 libpython3.10.dylib           	       0x105139880 _PyEval_EvalFrameDefault + 15136
349289 libpython3.10.dylib           	       0x105135c5c _PyEval_Vector + 140
-------- RECURSION 2, LEVEL 1
349290 libpython3.10.dylib           	       0x105199d9c pymain_run_module + 200
349291 libpython3.10.dylib           	       0x105199578 Py_RunMain + 840
349292 libpython3.10.dylib           	       0x105199c28 pymain_main + 324
349293 libpython3.10.dylib           	       0x105199cc8 Py_BytesMain + 40
349294 dyld                          	       0x18c1c5d54 start + 7184
CPython versions tested on:

3.10

Operating systems tested on:

macOS

Output from running 'python -VV' on the command line:

Python 3.10.18 (main, Aug 7 2025, 15:26:36) [Clang 17.0.0 (clang-1700.0.13.3)]

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 phần triển khai cProfile và _lsprof xung quanh RotatingTree_Enum và _lsprof_Profiler_getstats, sử dụng trace SIGSEGV trên macOS làm triệu chứng được báo cáo. Tìm một reproducer cho lần chạy cProfile của Python 3.10, sau đó xác minh rằng quá trình profiling hoàn tất mà không bị tràn stack hoặc crash.

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

Đánh giá

Công nghệ
python
Lĩnh vực
performance, tooling
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
32/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.