Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open Beginner friendly
#1,748 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c
Domain
compilers

Research direction

Start with the four named sites: builtin_dispatch in src/builtins.c around line 5946, vm_index_is_int in src/vm.c, the list arm of flat_index_at in src/builtins_tensor.c, and finite_num_to_byte. Reproduce with the dispatch snippet from the issue under make asan to see the UBSan float-cast-overflow report. Done when each site range-checks the double before casting (NaN-false), the grep -n '(int)' src/*.c sweep is classified, and the repro prints the value error with no runtime error: line.

Written by the indexing model from the issue text.

Description

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.
Dominant language
C
Stars
3
Forks
7
Avg merge
8h 43m
Merged PRs (30d)
253

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from InauguralSystems/EigenScript

All issues in InauguralSystems/EigenScript

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.