fix: segment time units, params pointer lifetimes, getter bounds checks - #14
Merged
Merged
Conversation
- Segment timestamps are now milliseconds. whisper.cpp reports centiseconds; full_get_segment_timestamps passed them through, so Segment::start_ms/end_ms, start_seconds()/end_seconds() and stream callback times were 10x too small. - FullParams owns suppress_regex and prompt_tokens and wires them up in as_raw(). suppress_regex previously pointed at a freed CString, and prompt_tokens at a borrowed slice that dangled after move/clone. - WhisperState result getters validate segment/token indices before calling whisper.cpp, which does not bounds-check. Result/Option getters return Err/None; plain-value getters panic like slice indexing. - Expose WhisperState::full_get_segment_no_speech_prob() and use it in the temperature-fallback transcriber instead of a raw FFI call.
rmorse
force-pushed
the
fix/core-soundness
branch
from
September 24, 2026 18:43
f9ba2a3 to
720bf49
Compare
Member
Author
|
Closing and reopening to trigger CI after retargeting to develop. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes existing bugs found while reviewing the crate for the whisper.cpp 1.9 upgrade.
full_get_segment_timestamps()passed them through, soSegment::start_ms/end_ms,start_seconds()/end_seconds()andWhisperStreamPcm::runcallback times were 10x too small. Fixed at the single conversion point, which coverstranscribe*,WhisperStream,WhisperStreamPcmand the fallback transcriber.FullParams::suppress_regex(). TheCStringwas dropped at the end of the setter while whisper.cpp kept the pointer.FullParams::prompt_tokens(). It stored a borrowed slice pointer in aClone + Send + Syncstruct. Tokens are now copied.Result/Optiongetters now returnErr/None; plain-value getters panic like slice indexing (documented under# Panics).WhisperState::full_get_segment_no_speech_prob(), replacing a raw FFI call in the fallback transcriber.The
language/initial_promptsetters no longer write pointers into the inner struct either;as_raw()is the single place pointers are wired up, and it is the only path params take to C.Notes
developafter chore: update whisper.cpp pin to 1.9.4-dev (stream-pcm de8fb5fd) #13 merged.WhisperState::full_parallelis also broken (upstream writes results to the context's default state, which the wrapper never reads) but is not changed here. It will be reimplemented in Rust in a follow-up.whisper_token_datafromfull_get_token_data()is left unchanged and now documented as centiseconds.Validation
Windows / MSVC, test models from
cargo xtask test-setup:cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo clippy -p whisper-cpp-plus --all-targets --features async -- -D warningscargo test --workspace -- --test-threads=1: 124 passed, none skippedcargo test -p whisper-cpp-plus --features async -- --test-threads=1: 112 passedcargo doc -p whisper-cpp-plus --no-deps: no warningsNew tests:
paramsunit tests: string params and prompt tokens stay valid after the original params are cloned and dropped;None/empty map to null.real_audio: jfk.wav's last segment ends near the audio length in ms (the old code gave ~1/10th); every getter rejects out-of-range indices withErr/None/panic.