Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

UB: (int) cast of a user double outside int range in dispatch / vm_index_is_int / flat_index_at

Đang mở Phù hợp với người mới
#1,748 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

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

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c
Lĩnh vực
compilers

Hướng nghiên cứu

Bắt đầu từ bốn vị trí đã nêu: builtin_dispatch trong src/builtins.c khoảng dòng 5946, vm_index_is_int trong src/vm.c, nhánh danh sách của flat_index_at trong src/builtins_tensor.c, và finite_num_to_byte. Tái hiện bằng đoạn mã dispatch trong issue với make asan để thấy báo cáo UBSan float-cast-overflow. Hoàn thành khi mỗi vị trí kiểm tra khoảng giá trị của double trước khi ép kiểu (NaN cho kết quả false), việc quét grep -n '(int)' src/*.c đã được phân loại, và chương trình tái hiện in ra lỗi value mà không có dòng runtime error: nào.

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

Mô tả

area:runtime-vm

Found while building #1746 Phase 1. Several sites convert a user double to int with a bare (int) cast before any range check. For |x| >= 2^31 (today: up to ±1e308; under an IEEE build also inf/NaN) that is undefined behaviour, and UBSan's float-cast-overflow (on in every ASan variant) reports it.

Repro (any asan build):

define g(x) as:
    return x
d is dispatch
print of (d of [[g], 1e308, 5])

-> src/builtins.c:5946:20: runtime error: 1e+308 is outside the range of representable values of type 'int' (then the intended dispatch key must be an integer raise).

Sites: builtin_dispatch (builtins.c, (int)eigs_num_arg(key_v, ...)), vm_index_is_int (vm.c), flat_index_at list arm (builtins_tensor.c), finite_num_to_byte ((int)fmod(x,256) with a NaN). The #1746 experiment guards only vm_index_is_int, only under -DEIGS_IEEE.

Done when

  • Each listed site range-checks (!(d >= INT_MIN && d <= INT_MAX) style, NaN-false) before the cast, and the sweep grep -n '(int)' src/*.c over user-double conversions is classified.
  • The repro above is clean under make asan (no runtime error:), and still raises value.
Ngôn ngữ chính
C
Star
3
Fork
7
Merge trung bình
8 giờ 43 phút
Pull request đã merge (30 ngày)
253

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

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.

Issue khác của InauguralSystems/EigenScript

Tất cả issue của InauguralSystems/EigenScript

Issue tương tự

Thêm issue về C

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.