Apache SIGTERM causes module shutdown to run at runtime
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C
- Star
- 40.4k
- Fork
- 8.2k
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 96
Mô tả
Description
Apache workers tends to sometimes crash when killed via SIGTERM:
Sample trace:
#2 php_module_shutdown () at ./main/main.c:2455
#3 0x00007fee0fbfc83d in php_module_shutdown_wrapper (sapi_globals=<optimized out>) at ./main/main.c:2448
#4 0x00007fee0fce6d05 in php_apache_child_shutdown (tmp=<optimized out>) at ./sapi/apache2handler/sapi_apache2.c:422
#5 0x00007fee11324d2e in apr_pool_destroy () from /usr/lib/x86_64-linux-gnu/libapr-1.so.0
#6 0x00007fee10f83303 in clean_child_exit () from /usr/lib/apache2/modules/mod_mpm_prefork.so
#7 0x00007fee10f83341 in just_die () from /usr/lib/apache2/modules/mod_mpm_prefork.so
#8 0x00007fee0fc866cd in zend_signal_handler (signo=signo@entry=15, siginfo=siginfo@entry=0x7fffe103fc30, context=context@entry=0x7fffe103fb00) at ./Zend/zend_signal.c:217
#9 0x00007fee0fc86873 in zend_signal_handler_defer (signo=15, siginfo=0x7fffe103fc30, context=0x7fffe103fb00) at ./Zend/zend_signal.c:102
#10 <signal handler called>
#11 0x00007fee11203bbf in __GI___poll (fds=fds@entry=0x7fffe1040890, nfds=nfds@entry=1, timeout=86400000) at ../sysdeps/unix/sysv/linux/poll.c:29
<a mysql function here>
The specific crash location within php_module_shutdown can vary quite a bit, depending on when exactly the signal handler was called.
But in particular, PHP does quite a lot of cleanup during module shutdown, and most is neither signal safe, nor can refcounts be relied on being correct.
I'd expect PHP to avoid any complex operations (like a module shutdown) upon receiving a SIGTERM signal. (Just like PHP also avoids doing special handling for CLI processes receiving a SIGTERM.)
PHP Version
PHP 7.4 - 8.4
Operating System
No response
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
Bắt đầu với php_apache_child_shutdown trong sapi/apache2handler/sapi_apache2.c và đường đi của php_module_shutdown trong main/main.c, sau đó kiểm tra việc xử lý SIGTERM trong Zend/zend_signal.c. So sánh đường đi của Apache worker với hành vi CLI SIGTERM được mô tả trong issue và tái hiện Apache shutdown trace. Hoàn tất khi SIGTERM không còn đi vào unsafe module-shutdown cleanup trong các Apache worker.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- apache, c, php
- Lĩnh vực
- backend, 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
- 35/100