php / php/php-src

pcntl_signal for SIGILL/SIGFPE/SIGSEGV/SIGBUS should add addr as int or string, not double

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

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

Bug Status: Needs Triage
Ngôn ngữ chính
C
Star
40.4k
Fork
8.1k
Merge trung bình
2 ngày 13 giờ
Pull request đã merge (30 ngày)
96

Mô tả

Description

add_assoc_double_ex is called in combination with a cast to zend_long - add_assoc_long_ex may have been intended? (There's one question about what's best for how negative zend_longs should be handled (high bit of pointer set), where pointers aren't actually negative) - keeping them negative seems better than sometimes using an int and sometimes using a string.

Motivation: Use 64-bit integers when it can properly represent the value. Don't use doubles when they might lose precision (e.g. virtual memory may allow numbers over the largest integer a double can safely represent?)
(not a priority for me, I'm just really surprised to see a float)

The following code:

<?php // Hackish example of a proof of concept userland signal handler to debug in an emergency,
// note that running any php snippets may fail again or have unexpected effects if php has already segfaulted
pcntl_signal(SIGSEGV, function (...$args) {
    echo "In signal handler\n";
    flush();
    var_dump($args);
    flush();
    debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
    flush();
    exit(139);
});
pcntl_async_signals(true);
sleep(20);
// call 'kill -USR1 PID_OF_PHP' to attempt to simulate a segfault
// ext/pcntl/pcntl.c
			case SIGILL:
			case SIGFPE:
			case SIGSEGV:
			case SIGBUS:
				add_assoc_double_ex(user_siginfo, "addr", sizeof("addr")-1, (zend_long)siginfo->si_addr);
				break;

Resulted in this output:

In signal handler
array(2) {
  [0]=>
  int(11)
  [1]=>
  array(4) {
    ["signo"]=>
    int(11)
    ["errno"]=>
    int(0)
    ["code"]=>
    int(0)
    ["addr"]=>
    float(4294967486499)
  }
}
#0  {closure}(11, Array ([signo] => 11,[errno] => 0,[code] => 0,[addr] => 4294967486499)) called at [/usr/local/tyson/php-src/test.php:12]

But I expected this output instead on 64-bit platforms:

    ["addr"]=>
    int(4294967486499)
PHP Version

5.x-8.3-dev

Operating System

No response

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 ext/pcntl/pcntl.c với phần xử lý SIGILL, SIGFPE, SIGSEGV và SIGBUS được nêu trong issue, sau đó chạy ví dụ trình xử lý tín hiệu PHP được cung cấp trên nền tảng 64-bit. Công việc được xem là hoàn tất khi giá trị addr được biểu diễn dưới dạng số nguyên nếu có thể biểu diễn an toàn, thay vì dưới dạng double; issue cũng để ngỏ việc giải quyết cách xử lý zend_long âm đối với các con trỏ có bit cao nhất được thiết lập.

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, php
Lĩnh vực
operating-systems
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
42/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.