Fix SherpaOnnx finalizer crash with DllNotFoundException#745
Conversation
Suppress fatal crashes caused by SherpaOnnx.OfflineTts finalizer calling SherpaOnnxDestroyOfflineTts when native DLL is unavailable. Changes: - PiperTextToSpeechClient: gracefully handle DllNotFoundException in constructor (TTS disabled gracefully), add GC.SuppressFinalize after dispose to prevent finalizer from calling native code during GC - App.xaml.cs: improved OnDomainUnhandledException logging for SherpaOnnx native DLL errors - Crash prevention relies on exe.config legacyUnhandledExceptionPolicy and GC.SuppressFinalize (IsTerminating is readonly in .NET 10) Fixes repeated crashes: System.DllNotFoundException: Unable to load DLL 'sherpa-onnx-c-api' at SherpaOnnx.OfflineTts.Finalize()
# Conflicts: # src/OpenClaw.Tray.WinUI/App.xaml.cs
|
Codex review: needs real behavior proof before merge. Reviewed June 15, 2026, 7:22 AM ET / 11:22 UTC. Summary Reproducibility: yes. for a source-level path: the related crash report captured Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Merge a narrow Piper finalizer mitigation only after redacted Windows runtime proof and the repository-required build/shared/tray validation are available for the final head. Do we have a high-confidence way to reproduce the issue? Yes for a source-level path: the related crash report captured Is this the best way to solve the issue? Mostly yes: preloading the native library before wrapper construction and suppressing finalization before best-effort cleanup is a narrow mitigation. The solution still needs real Windows proof because the added tests only inspect source ordering. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c75140696d4d. Label changesLabel changes:
Label justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
Preload the Sherpa native library before constructing its finalizable wrapper and suppress finalization before best-effort cleanup. Co-authored-by: suportewmit-cmyk <suportewmit@gmail.com>
Suppress fatal crashes caused by SherpaOnnx.OfflineTts finalizer calling SherpaOnnxDestroyOfflineTts when native DLL is unavailable.
Changes:
Fixes repeated crashes: System.DllNotFoundException: Unable to load DLL 'sherpa-onnx-c-api' at SherpaOnnx.OfflineTts.Finalize()