Skip to content

Fix CLI multi-color slicing crash for single-extruder AMS printers (P1S/P1P/X1C)#10466

Open
ryanhebert wants to merge 1 commit intobambulab:masterfrom
ryanhebert:fix-cli-multicolor-crash
Open

Fix CLI multi-color slicing crash for single-extruder AMS printers (P1S/P1P/X1C)#10466
ryanhebert wants to merge 1 commit intobambulab:masterfrom
ryanhebert:fix-cli-multicolor-crash

Conversation

@ryanhebert
Copy link
Copy Markdown

Summary

Fixes ACCESS_VIOLATION crash in CLI multi-color slicing when using --load-assemble-list with single-extruder AMS printers.

Changes

Three fixes in src/libslic3r/PrintConfig.cpp:

  1. Null check for filament_map (line 8460): printer_config.option<ConfigOptionInts>("filament_map") returns null in CLI mode since filament_map is initialized by the GUI workflow. Added null check with early return.

  2. Null checks for extruder_type and nozzle_volume_type (lines 8465-8466): dynamic_cast returns null when these options aren't present in standalone profile files. Added null check with early return.

  3. Bounds clamping on get_at() calls (lines 8478-8479, 8265): filament_maps contains AMS slot numbers (e.g., [3, 4, 1]) used as indices into extruder_type/nozzle_volume_type arrays that typically have only 1-2 entries. get_at(3) on a 2-element array → out-of-bounds → crash. Fixed with std::clamp().

Root Cause

For single-extruder AMS printers (P1S, P1P, X1C), support_different_extruders() returns true due to extruder_variant_list: ["Direct Drive Standard", "Direct Drive High Flow"]. This triggers the multi-extruder code path in update_values_to_printer_extruders_for_multiple_filaments(), which accesses fields that are either uninitialized (CLI mode) or have fewer entries than the filament map indices expect.

Testing

CLI command that crashes before fix:

bambu-studio --load-assemble-list assemble.json \
  --load-settings "machine.json;process.json" \
  --load-filaments "filament.json;..." \
  --slice 0 --export-3mf sliced.3mf

Crash trace:

update_filament_maps_to_config: filament maps changed after pre-slicing.
update_values_to_printer_extruders_for_multiple_filaments, Line 8449: different nozzle volume processing
[ACCESS VIOLATION - exit code -1073741819]

Fixes #10465

Note: Same fix submitted to OrcaSlicer at OrcaSlicer/OrcaSlicer#13406

Three fixes in update_values_to_printer_extruders_for_multiple_filaments()
and update_values_to_printer_extruders():

1. Add null check for filament_map option - not initialized in CLI mode,
   causing null pointer dereference at line 8460.

2. Add null checks for extruder_type and nozzle_volume_type options -
   may not be present when profiles are loaded standalone via CLI.

3. Clamp array index in get_at() calls - filament_maps contains AMS
   slot numbers (e.g., [3, 4, 1]) which exceed the extruder_type and
   nozzle_volume_type array sizes (typically 1-2 entries) on
   single-extruder AMS printers like P1S, P1P, X1C.

Without these fixes, CLI multi-color slicing via --load-assemble-list
crashes with ACCESS_VIOLATION after slicing completes successfully.

Fixes bambulab#10465
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI multi-color slicing crashes in update_values_to_printer_extruders_for_multiple_filaments for P1S profile

1 participant