Skip to content

Config::block_threads() multiplies kernel.toml dimensions unchecked #53

Description

@vyncint

TodayConfig::block_threads() is .product() over the three block dimensions as u64 (space/lib.rs:61–69). The values come from kernel.toml (spec.rs:172, any non-negative integer). Three large dimensions overflow: a panic in a debug build, a wrapped value in release that then feeds estimate and the gate's threads > WARP_SIZE test. Everything downstream is careful — the constraint evaluator returns "multiplication overflow" (constraint.rs:196), grid_blocks saturates — so this one function is the exception.

Fix. checked_mul folding to Result<u64, SpaceError>; callers propagate. Reject at spec load a block dimension above CUDA's 1024-thread block limit with a clear message, so the overflow cannot be reached from a valid spec in the first place. A proptest over three u64 dims that asserts no panic.

Done when

  • block_threads cannot panic or wrap; the proptest is in the suite.
  • A kernel.toml with block_x = 2048 is refused at load with a message naming the limit.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions