Turning thread kernel: a NaN pitch passes the pitch guard and gives a NaN toolpath as Ok

Open Beginner friendly
#4,707 1 comment 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
70/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
backend

Research direction

Read crates/motion/src/turning/thread.rs around line 133 and the existing tests in crates/motion/tests/turning/turning_thread.rs. Add the provided NaN pitch test and run the turning thread tests; the issue says the test should pass as a pinning test when the kernel rejects non-finite pitch. The report also identifies similar guards for depth and infeed, but says those were not tested.

Written by the indexing model from the issue text.

Description

area:turning bug effort:low P7 source:agent

What happens

Turning thread kernel: a NaN pitch passes the pitch guard and gives a NaN toolpath as Ok.

Fix

Make the kernel guard refuse a non-finite pitch (!(p.pitch > 0.0 && p.pitch.is_finite())), the same rule as the app's pos() check.

Verification on upstream main ca680c2d

The code audit #4653 found this (Grok). An Opus agent reproduced it with a failing test. Its report follows:

F2 REAL [P7] missing refusal - crates/motion/src/turning/thread.rs:133

Test (added to crates/motion/tests/turning/turning_thread.rs, not committed):

#[test]
fn averify_f2_nan_pitch() {
    let mut p = th(14.3, 7.7);
    p.pitch = f64::NAN;
    let e = thread(&threaded(), &p).expect_err("non-finite pitch");
    assert!(format!("{e:?}").contains("pitch"), "{e:?}");
}

Result: FAILED. thread returned Ok(Toolpath) with 10 moves, and all positions between the first and last move are NaN. cycles is empty, and the note is "threading: the passes did not lay as planned - no thread cycle record".

Reasoning: p.pitch <= 0.0 is false for NaN, so the guard does not fire. The kernel then sends out a NaN toolpath as Ok. A user cannot reach this from the app: crates/app/src/operation/types/sane.rs:1276 checks pos(*pitch), and pos (line 138) is v.is_finite() && v > 0.0. So this is a kernel guard that does not catch non-finite numbers. P7 is correct, but a direct caller of the kernel API gets bad output with no error. The fix should replace the check with !(p.pitch.is_finite() && p.pitch > 0.0). The same fix applies to depth and infeed, which have the same <= 0.0 form. I did not test those two. No open issue covers it.

Cleanup: I removed the worktree .claude/worktrees/averify-4653008 and the ref refs/verify/audit-4653008. Nothing was written to GitHub.

Done means

The test above passes as a pinning test.

Dominant language
Rust
Stars
8
Forks
11
Avg merge
10h 3m
Merged PRs (30d)
927

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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 NeoTech/Camcraft

All issues in NeoTech/Camcraft

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.