Skip to content

ML: fix panic in featuresToTensorAdvanced for 100/106/110-feature models - #72

Closed
Tumult1337 wants to merge 1 commit into
awlx:mainfrom
Tumult1337:pr/ml-onnx
Closed

ML: fix panic in featuresToTensorAdvanced for 100/106/110-feature models#72
Tumult1337 wants to merge 1 commit into
awlx:mainfrom
Tumult1337:pr/ml-onnx

Conversation

@Tumult1337

Copy link
Copy Markdown
Contributor

Fix a panic in featuresToTensorAdvanced for 100/106/110-feature ONNX models (bounds-clamped feature copy).

Validation: go build ./... clean; go test ./pkg/ml passes.

…dels

featuresToTensorAdvanced wrote fixed offsets copy(tensor[95:105], ...)
and copy(tensor[105:115], ...) unconditionally regardless of the
allocated tensor length. LoadONNXModel's auto-detect probe includes
sizes 100, 106, and 110 (onnx.go loadONNXModelInternal), all narrower
than the fixed 115-index write, so a model auto-detected at one of
those sizes panicked with a slice-bounds-out-of-range on the first
prediction carrying event history, crashing the analyzer process
(engine.Predict runs on the detection goroutine with no recover).

Add copyTruncated, which clamps each write to the tensor's actual
capacity, and route the fingerprint/behavioral feature copies through
it so smaller auto-detected sizes get a truncated but valid tensor
instead of a panic. Sizes >=116 are unaffected (the existing branches
already guard capacity for those layouts).
awlx added a commit that referenced this pull request Aug 8, 2026
@awlx

awlx commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Superseded by and merged through #77, which preserves this contribution and includes the follow-up fixes. Thanks for the contribution!

@awlx awlx closed this Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants