Sending many signals to a Python process crashes the interpreter
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 36k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
Bug report
Bug description:
Consider the following simple program (test-breakage.py):
from time import sleep
import os
import signal
class Foreman:
def __init__(self):
signal.signal(signal.SIGUSR1, self.handle_sigusr1)
pid = os.getpid()
print("Test script created, my pid is %s", pid)
with open("/tmp/test-breakage.pid", "w") as f:
f.write(str(pid))
def handle_sigusr1(self, sig, frame):
print("handle_sigusr1")
def run_forever(self):
sleep(3600)
Foreman().run_forever()
Now, a tool to send "a lot" of signal to it:
import os
import sys
import signal
pid = int(sys.argv[1])
iterations = int(sys.argv[2])
for i in range(iterations):
os.kill(pid, signal.SIGUSR1)
Or, if you want the signals to be sent more quickly, implemented in c:
#include <stdlib.h>
#include <signal.h>
int main(int argc, char*argv[]) {
long pid, iterations;
if (argc > 2) {
pid = strtol(argv[1], NULL, 0);
iterations = strtol(argv[2], NULL, 0);
for (int i = 0; i < iterations; i++) {
kill(pid, SIGUSR1);
}
}
return 0;
}
Running these scripts with "sufficiently high" numbers results in various crashes in test-breakage
- Exit with "User defined signal 1" (shouldn't happen, we've defined a handler)
RuntimeErrorwithout any further information- Exit without any printed string
- RuntimeError: reentrant call inside <_io.BufferedWriter name=''>
(In all cases, after repeating "handle_sigusr1" a number of times first)
tested on Linux w. Python 3.10
CPython versions tested on:
3.10
Operating systems tested on:
Linux
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Start by reproducing the failure with the test-breakage.py signal handler and the Python or C signal-sending scripts on Linux. Compare the reported outcomes under sustained SIGUSR1 delivery; done means the interpreter remains stable and the registered handler continues to behave correctly without the listed crashes or unintended termination.
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
- operating-systems
- 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
- Khá rõ ràng
- Mức phù hợp với người mới
- 42/100