Skip to content

fix: crash guards for LLM endpoint URL + ASR model loading - #623

Merged
H-Chris233 merged 1 commit into
Open-Less:betafrom
H-Chris233:fix/crash-guards-llm-endpoint-url-asr-model-validation
Jun 9, 2026
Merged

H-Chris233 merged 1 commit into
Open-Less:betafrom
H-Chris233:fix/crash-guards-llm-endpoint-url-asr-model-validation

Conversation

@H-Chris233

@H-Chris233 H-Chris233 commented Jun 9, 2026 •

Copy link
Copy Markdown
Collaborator

User description

修复两个用户侧崩溃场景,详见 H-Chris233#2


PR Type

Bug fix


Description

  • Validate ASR model files before FFI call to prevent segfaults

  • Guard LLM provider construction with catch_unwind to avoid panics

  • Auto-prepend http:// to endpoint URLs missing scheme

  • Replace expect() with safe retry fallback in polish module


Diagram Walkthrough

flowchart LR
  A["ASR: Validate model files"] --> B["Prevents segfault"]
  C["LLM: catch_unwind around provider"] --> D["Prevents process kill"]
  E["Endpoint: auto-prepend http://"] --> F["Fixes TLS handshake failure"]
  G["Polish: safe try_clone fallback"] --> H["Prevents panic on non-clonable body"]
Loading

File Walkthrough

Relevant files
Bug fix
test_run.rs
Add ASR model file validation before C FFI call                   

openless-all/app/src-tauri/src/asr/local/test_run.rs

  • Added integrity checks for required model files (config.json,
    vocab.json, merges.txt) existence and non-empty.
  • Validate that .safetensors files exist and are at least 1KB.
  • Errors now returned before C FFI call to prevent segfaults.
+37/-0   
llm_pipeline.rs
Wrap LLM provider creation with panic guard and fix URL scheme

openless-all/app/src-tauri/src/coordinator/llm_pipeline.rs

  • Wrapped all four calls to build_active_llm_provider with catch_unwind.
  • Panics are caught, logged, and returned as error instead of killing
    process.
  • Auto-prepend http:// to endpoint URL if scheme missing (e.g., user
    typed IP:port).
+53/-7   
polish.rs
Replace expect() with safe retry fallback for non-clonable body

openless-all/app/src-tauri/src/polish.rs

  • Replaced try_clone().expect() with safe fallback: if body not
    clonable, send once without retry.
+10/-3   

Three defensive layers to prevent user-facing crashes:

1. coordinator/llm_pipeline.rs: Auto-prepend http:// when endpoint URL is
   missing scheme (user types 192.168.1.100:8080/v1 without http://).
   Add catch_unwind guards around all 4 build_active_llm_provider call
   sites to turn panics (e.g. poisoned credentials mutex) into logged
   errors instead of process kills.

2. polish.rs: Replace try_clone().expect() with safe fallback — if the
   request body isn't clonable, send once without retry instead of
   panicking the process.

3. test_run.rs: Validate model files (config.json, vocab.json,
   merges.txt exist and are non-empty; at least one .safetensors >= 1KB)
   before calling into the C FFI qwen_load / qwen_transcribe_audio,
   preventing segfaults from corrupted/incomplete model downloads.
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ No major issues detected

@H-Chris233
H-Chris233 merged commit bba2c90 into Open-Less:beta Jun 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant