Fix second CLI segfault during --slice in extruder variant config #152

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

Originally created by @niccolodevries on 3/25/2026

Summary

Fixes a second CLI segfault discovered after #12719. While #12719 fixed the NULL m_plater dereference in PartPlate::set_shape() (which crashed during model arrangement), this PR fixes a separate SIGSEGV that occurs later during Print::apply() when the slicer processes extruder variant configurations.

In CLI mode, config options like filament_map, extruder_type, and nozzle_volume_type may not be present in the merged config when loading individual JSON profile files. The code unconditionally dereferences these without NULL checks, causing a segfault at address 0x8 (NULL + struct member offset).

Additionally, option lookups in the switch/case blocks (e.g., this->option<ConfigOptionInts>(key)) can return nullptr for keys that exist in the config definition but not in the actual config values.

Zero impact on GUI mode where these options are always populated.

Steps to reproduce

Requires #12719 to be applied first (otherwise the earlier segfault masks this one).

OrcaSlicer \
  --load-settings "machine/Bambu Lab P2S 0.4 nozzle.json;process/0.20mm Standard @BBL P2S.json" \
  --load-filaments "filament/Bambu PLA Basic @BBL P2S.json" \
  --slice 0 \
  --export-3mf output.3mf \
  model.stl
# Crashes with exit code 139 (SIGSEGV)

After fix

$ OrcaSlicer \
  --load-settings "machine/Bambu Lab P2S 0.4 nozzle.json;process/0.20mm Standard @BBL P2S.json" \
  --load-filaments "filament/Bambu PLA Basic @BBL P2S.json" \
  --slice 0 \
  --export-3mf 3DBenchy_P2S.3mf \
  3DBenchy.stl

$ echo $?
0

Changes

src/libslic3r/PrintConfig.cpp:

  • Add NULL guard for opt_extruder_type / opt_nozzle_volume_type in both update_values_to_printer_extruders() and update_values_to_printer_extruders_for_multiple_filaments() — return early if missing
  • Add NULL guard for filament_map option in update_values_to_printer_extruders_for_multiple_filaments()
  • Add if (!opt) continue; for all option type cases in the switch blocks of both functions, preventing NULL dereference when a config key is defined but has no value

src/libslic3r/PrintApply.cpp:

  • Add NULL guard for filament_map in Print::apply() with fallback to {1} (matching the config definition default)
*Originally created by @niccolodevries on 3/25/2026* ## Summary Fixes a **second CLI segfault** discovered after #12719. While #12719 fixed the NULL `m_plater` dereference in `PartPlate::set_shape()` (which crashed during model arrangement), this PR fixes a separate SIGSEGV that occurs later during `Print::apply()` when the slicer processes extruder variant configurations. In CLI mode, config options like `filament_map`, `extruder_type`, and `nozzle_volume_type` may not be present in the merged config when loading individual JSON profile files. The code unconditionally dereferences these without NULL checks, causing a segfault at address `0x8` (NULL + struct member offset). Additionally, option lookups in the switch/case blocks (e.g., `this->option<ConfigOptionInts>(key)`) can return `nullptr` for keys that exist in the config *definition* but not in the actual config values. Zero impact on GUI mode where these options are always populated. ## Steps to reproduce Requires #12719 to be applied first (otherwise the earlier segfault masks this one). ```bash OrcaSlicer \ --load-settings "machine/Bambu Lab P2S 0.4 nozzle.json;process/0.20mm Standard @BBL P2S.json" \ --load-filaments "filament/Bambu PLA Basic @BBL P2S.json" \ --slice 0 \ --export-3mf output.3mf \ model.stl # Crashes with exit code 139 (SIGSEGV) ``` ## After fix ``` $ OrcaSlicer \ --load-settings "machine/Bambu Lab P2S 0.4 nozzle.json;process/0.20mm Standard @BBL P2S.json" \ --load-filaments "filament/Bambu PLA Basic @BBL P2S.json" \ --slice 0 \ --export-3mf 3DBenchy_P2S.3mf \ 3DBenchy.stl $ echo $? 0 ``` ## Changes **`src/libslic3r/PrintConfig.cpp`:** - Add NULL guard for `opt_extruder_type` / `opt_nozzle_volume_type` in both `update_values_to_printer_extruders()` and `update_values_to_printer_extruders_for_multiple_filaments()` — return early if missing - Add NULL guard for `filament_map` option in `update_values_to_printer_extruders_for_multiple_filaments()` - Add `if (!opt) continue;` for all option type cases in the switch blocks of both functions, preventing NULL dereference when a config key is defined but has no value **`src/libslic3r/PrintApply.cpp`:** - Add NULL guard for `filament_map` in `Print::apply()` with fallback to `{1}` (matching the config definition default)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/OrcaSlicer#152