fix: Prevent app crash from SIGSEGV in Bambu networking DLL #127

Open
opened 2026-04-05 16:18:33 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @JustNotesa on 3/27/2026

Summary

Fixes #9813 — OrcaSlicer crashes (SIGSEGV) when the Bambu networking plugin's MQTT thread encounters a connection failure, particularly on macOS Sequoia with LAN connections.

Root cause: The proprietary libbambu_networking DLL crashes internally at mqtt::token::on_failure(MQTTAsync_failureData*) with a null pointer dereference on its own MQTT send thread. Since the DLL is closed-source, we cannot fix the bug itself.

Fix approach: Treat the networking DLL as an unreliable external tool and add defensive crash handling:

  • New DllCrashGuard (POSIX + Windows): Global signal/exception handler that catches SIGSEGV on DLL-owned threads (e.g. MQTTAsync_sendThread) and terminates only that thread instead of the whole process
  • dll_safe_call() wrapper: Uses sigsetjmp/siglongjmp (POSIX) or SEH (Windows) to recover from crashes during DLL calls initiated by OrcaSlicer
  • All BBLPrinterAgent DLL calls wrapped with dll_safe_call() protection
  • Async crash detection in PrintJob/SendJob with user-friendly error message instead of silent crash-to-desktop

Platform support

Platform Mechanism Coverage
macOS/Linux sigaction + sigsetjmp + pthread_exit DLL-owned threads + caller threads
Windows Vectored Exception Handler + SEH DLL-owned threads + caller threads

Files changed

  • src/slic3r/Utils/DllCrashGuard.hpp/.cppNEW crash guard implementation
  • src/slic3r/Utils/BBLPrinterAgent.cpp — wrap all DLL calls with dll_safe_call()
  • src/slic3r/GUI/GUI_App.cpp — install crash handler at app startup
  • src/slic3r/GUI/Jobs/PrintJob.cpp — detect async DLL crash, show error message
  • src/slic3r/GUI/Jobs/SendJob.cpp — detect async DLL crash, show error message
  • src/slic3r/CMakeLists.txt — add new source files

Test plan

  • Build on macOS (ARM64) — verified locally
  • Build on Windows
  • Build on Linux
  • Test LAN print to Bambu printer with stable connection
  • Test LAN print with network interruption (unplug ethernet/disable WiFi during print)
  • Verify app shows error message instead of crashing when DLL SIGSEGV occurs
  • Test that normal (non-crashing) print flow is unaffected by the signal handler

🤖 Generated with Claude Code

*Originally created by @JustNotesa on 3/27/2026* ## Summary Fixes #9813 — OrcaSlicer crashes (SIGSEGV) when the Bambu networking plugin's MQTT thread encounters a connection failure, particularly on macOS Sequoia with LAN connections. **Root cause**: The proprietary `libbambu_networking` DLL crashes internally at `mqtt::token::on_failure(MQTTAsync_failureData*)` with a null pointer dereference on its own MQTT send thread. Since the DLL is closed-source, we cannot fix the bug itself. **Fix approach**: Treat the networking DLL as an unreliable external tool and add defensive crash handling: - **New `DllCrashGuard`** (POSIX + Windows): Global signal/exception handler that catches SIGSEGV on DLL-owned threads (e.g. `MQTTAsync_sendThread`) and terminates only that thread instead of the whole process - **`dll_safe_call()` wrapper**: Uses `sigsetjmp`/`siglongjmp` (POSIX) or SEH (Windows) to recover from crashes during DLL calls initiated by OrcaSlicer - **All `BBLPrinterAgent` DLL calls** wrapped with `dll_safe_call()` protection - **Async crash detection** in `PrintJob`/`SendJob` with user-friendly error message instead of silent crash-to-desktop ### Platform support | Platform | Mechanism | Coverage | |----------|-----------|----------| | macOS/Linux | `sigaction` + `sigsetjmp` + `pthread_exit` | DLL-owned threads + caller threads | | Windows | Vectored Exception Handler + SEH | DLL-owned threads + caller threads | ## Files changed - `src/slic3r/Utils/DllCrashGuard.hpp/.cpp` — **NEW** crash guard implementation - `src/slic3r/Utils/BBLPrinterAgent.cpp` — wrap all DLL calls with `dll_safe_call()` - `src/slic3r/GUI/GUI_App.cpp` — install crash handler at app startup - `src/slic3r/GUI/Jobs/PrintJob.cpp` — detect async DLL crash, show error message - `src/slic3r/GUI/Jobs/SendJob.cpp` — detect async DLL crash, show error message - `src/slic3r/CMakeLists.txt` — add new source files ## Test plan - [ ] Build on macOS (ARM64) — **verified locally** ✅ - [ ] Build on Windows - [ ] Build on Linux - [ ] Test LAN print to Bambu printer with stable connection - [ ] Test LAN print with network interruption (unplug ethernet/disable WiFi during print) - [ ] Verify app shows error message instead of crashing when DLL SIGSEGV occurs - [ ] Test that normal (non-crashing) print flow is unaffected by the signal handler 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/OrcaSlicer#127