OrcaSlicer icon indicating copy to clipboard operation
OrcaSlicer copied to clipboard

CLI --slice crashes (0xC0000005 access violation) loading any U1 "process" settings file via --load-settings

Open printomancy opened this issue 3 months ago • 5 comments

Is there an existing issue for this problem?

  • [x] I have searched the existing issues

Snapmaker_Orca Version

2.3.3 (also reproduced identically on 2.3.5 portable -- both report internal engine version 01.10.01.50)

Operating System (OS)

Windows

OS Version

Windows 10/11 (build 19041)

Additional system information

GPU: NVIDIA GeForce RTX 2070 SUPER (driver 32.0.16.1074) Ran via command line, not the GUI -- see repro steps below.

Printer

Snapmaker U1, 0.4mm nozzle

How to reproduce

Run the following from a command prompt (paths shortened for readability -- full paths point at the installed Snapmaker Orca resources\profiles\Snapmaker directory):

snapmaker-orca.exe --slice 0 --load-settings "machine\Snapmaker U1 (0.4 nozzle).json;process\0.20 Standard @Snapmaker U1 (0.4 nozzle).json" --load-filaments "filament\Snapmaker PLA @U1.json" --allow-newer-file --debug 5 --export-3mf output.gcode.3mf model.stl

Reproduced with 3 different U1 process profiles (0.20 Standard, its _old variant, and 0.08 Extra Fine), all at the 0.4mm nozzle, and with the process file loaded both before and after the machine file. Also reproduced identically on Snapmaker Orca 2.3.5 portable (both 2.3.3 and 2.3.5 report the same internal engine version 01.10.01.50).

Actual results

Log output stops immediately after: load setting file <...>\process\0.20 Standard @Snapmaker U1 (0.4 nozzle).json, with rule 1 -- no further log lines, no "no substitutions performed" confirmation (which does print for the preceding machine-type file). Process exits with code -1073741819 (0xC0000005, STATUS_ACCESS_VIOLATION). No output 3MF/gcode is produced.

Without loading a process file at all, the CLI instead fails cleanly (not a crash) with error: Slic3r::CLI::run 2334: process not compatible with printer -- so a process-type settings object is required, but loading one via --load-settings for the U1 crashes rather than succeeding.

Also confirmed the loaded machine config always logs an empty printer_model_id (loaded machine config ..., printer_model_id with nothing after it), even though the base model file (machine/Snapmaker U1.json) defines "model_id": "SM_U1". Patched a copy of the machine JSON to add "printer_model_id": "SM_U1" directly -- no change, log still shows it empty, suggesting this field is resolved internally (not read from the file) and the resolution is failing. Not fixed by --datadir pointing at an already-initialized user config directory either.

Expected results

Slicing completes and produces a .gcode.3mf output file, matching the documented OrcaSlicer CLI behavior (--slice, --load-settings, --load-filaments, --export-3mf). This blocks any headless/scripted slicing workflow for the U1 (print-farm automation, CI, etc.) -- the GUI works fine, but there's currently no working CLI path. Happy to provide the exact profile JSON files used, full debug logs, or test further builds if useful.

Project file & Debug log uploads

No project file could be exported -- the crash happens during --load-settings itself, before any output is produced, so there's nothing to Save project as... Debug log: with --debug 5 set, the CLI's own log output stops mid-line right after "load setting file ...process\0.20 Standard @Snapmaker U1 (0.4 nozzle).json, with rule 1" and never writes anything further (no crash dump appeared under %APPDATA%\Snapmaker_Orca\log either). I've quoted the exact stdout tail and exit code in the Actual results section above -- happy to paste the raw captured stdout/stderr text here on request, just let me know the preferred format since there's no populated log directory or project file this crash produces to attach.

Checklist of files to include

  • [ ] Log file
  • [ ] Project file

Anything else?

No response

printomancy avatar Aug 11 '26 00:08 printomancy

I found the root cause. It still happens on 2.4.0 on macOS (arm64): SIGSEGV, exit 139, with the same last log line. So the bug is cross-platform and has been present from 2.3.3 through 2.4.0.

It's a null-pointer dereference in DynamicPrintConfig::normalize_fdm(), triggered by wipe_tower_filament.

load_config_file in src/Snapmaker_Orca.cpp calls config.normalize_fdm() on each --load-settings file separately (line 1742 at v2.4.0). normalize_fdm() then runs this (src/libslic3r/PrintConfig.cpp:7746):

if (this->has("wipe_tower_filament")) {
    // If invalid, replace with 0.
    int extruder      = this->opt<ConfigOptionInt>("wipe_tower_filament")->value;
    int num_extruders = this->opt<ConfigOptionFloats>("nozzle_diameter")->size();   // <- nullptr

Without create=true, opt() returns nullptr for a missing key. nozzle_diameter is a machine key, so a process file never has it, and every 0.4-nozzle U1 process preset sets "wipe_tower_filament": "0". That is why the log stops right after load setting file ...process...json and never prints no substitutions performed.

Controls, using the shipped files unmodified (machine/Snapmaker U1 (0.4 nozzle).json + process/0.20mm Standard @Snapmaker U1 (0.4 nozzle).json, and a 20 mm cube STL):

process file result
as shipped exit 139, no output
wipe_tower_filament removed exit 0, plate_1.gcode written
wipe_tower_filament kept, nozzle_diameter added exit 0, plate_1.gcode written

Suggested fix: only range-check the key when the config actually has nozzle_diameter:

if (this->has("wipe_tower_filament") && this->has("nozzle_diameter")) {

This block isn't in upstream OrcaSlicer's normalize_fdm() (checked main), so the bug is specific to this fork. It is at PrintConfig.cpp:7416 in V2.3.6 as well.

Workaround until it's fixed: move wipe_tower_filament from the process JSON into the machine JSON. The machine file has nozzle_diameter, so the check is safe there, and the value still reaches the merged config.

A few things that bite straight after this one, in case they save someone the time:

  • run 2334: process not compatible with printer with a user machine preset. For a from: User machine, the CLI takes the "system name" from its inherits (line 1785). It then looks for that name in the process's compatible_printers (line 2261). A machine preset flattened from the system one still says inherits: fdm_U1, so it never matches. Set inherits to Snapmaker U1 (0.4 nozzle), or pass the machine as from: system.
  • The CLI doesn't resolve inherits for any preset type. Passing the shipped leaf presets slices with Orca's compiled-in defaults for everything the leaf doesn't set, e.g. travel_speed 120 instead of the U1's 500. Merge the chain yourself before passing it.
  • curr_bed_type defaults to Cool Plate. PLA then gets a 35 °C bed instead of 60 °C. Set "curr_bed_type": "Textured PEI Plate" in the process JSON.
  • --export-3mf needs an absolute --outputdir. With a relative one it fails with Unable to open the fileout/x.3mf.tmp, exit 243.
  • The empty printer_model_id you saw comes from line 1793, which looks the model up under a hard-coded profiles/BBL/machine_full/<printer_model>.json. That file never exists for Snapmaker printers. I saw no effect from it on slicing.

With all of the above, headless STL slicing of the U1 works on 2.4.0, including multi-filament (--load-filament-ids, prime tower, tool changes) and Orca's own slicing warnings in the log. A 3MF as input still crashes, which is a separate bug: #935.

rapha-ramos avatar Sep 28 '26 14:09 rapha-ramos

I can reproduce this on Snapmaker Orca 2.4.0, macOS 27.0.1 (Apple Silicon), and I think I've found the cause.

Root cause: wipe_tower_filament in the process file

I bisected the 129 keys of a flattened U1 process file (0.20mm Standard @Snapmaker U1 (0.4 nozzle)) and the crash comes down to one key: "wipe_tower_filament": "0".

  • A process file containing only type, from, name, compatible_printers and wipe_tower_filament → segfault (exit 139), log stops right after load setting file …process.json, with rule 1.
  • The same process file with only that key removed → slices normally and writes G-code.

In src/libslic3r/PrintConfig.cpp (tag v2.4.0, lines ~7746–7751, DynamicPrintConfig::normalize_fdm()):

if (this->has("wipe_tower_filament")) {
    // If invalid, replace with 0.
    int extruder      = this->opt<ConfigOptionInt>("wipe_tower_filament")->value;
    int num_extruders = this->opt<ConfigOptionFloats>("nozzle_diameter")->size();

nozzle_diameter is a machine setting, so it isn't present when a process file is loaded on its own. opt<ConfigOptionFloats>("nozzle_diameter") returns null, and ->size() dereferences it. The GUI never hits this because it always works on a merged config. The code is unchanged on release_2.4.1.

All U1 0.4 mm process presets I checked carry "wipe_tower_filament": "0", so every U1 process file crashes the CLI, which matches this report on Windows.

Suggested fix: guard the lookup, e.g.

if (this->has("wipe_tower_filament") && this->has("nozzle_diameter")) {

or auto *nd = this->opt<ConfigOptionFloats>("nozzle_diameter"); if (nd) { … }.

Workaround until then: remove wipe_tower_filament from the process JSON passed to --load-settings. Its default is already 0, so nothing changes. If you need a non-zero value, put it in the machine JSON instead (which contains nozzle_diameter). I confirmed the resulting G-code then records the carried value.

Related, for anyone slicing project 3MFs from the CLI on 2.4.0:

  • The version check compares the file against the internal engine version 01.10.01.50, so 2.4.0's own 3MFs are rejected; --allow-newer-file bypasses it. Note that it's a bare flag with no value, so --allow-newer-file 1 treats 1 as an input file. See #839.
  • After that bypass, project 3MFs still segfault in expand_plate_extruders() (#935). The wxTheApp == nullptr guard for that is on release_2.4.1.

zealousagenda avatar Oct 20 '26 12:10 zealousagenda

Recheck on 2.4.1 (Windows 11, 2026-10-28)

The preset-loading crash still reproduces on the official 2.4.1 Windows installation with bundled U1 0.4 mm presets. Two controlled probes narrow it down:

  • raw-system-presets: direct bundled inherited machine/process and filament files via --load-settings / --load-filaments: exit 3221225477 (0xC0000005), no G-code.
  • wipe-tower-filament: working flattened copies, adding only "wipe_tower_filament": "0" to the process: the same crash, no G-code.
  • baseline: flattened copies, machine from=system, that process key omitted: exit 0, one G-code, 925 s / 3.65 g for the 20 mm cube. The resulting config still reports wipe_tower_filament = 0.

Removing that key from a copied process works around the crash without modifying installed/user presets. The direct-preset case does not by itself establish a separate inheritance bug, because those presets also contain the problematic key.

Project file & Debug log uploads

Reproducer script and recorded results, pinned to the tested revision. The script generates the inputs and preserves each command (command.json), input settings, output and combined stdout/stderr (slicer.log) in a separate probe directory. Raw logs are not attached here. To reproduce with Python >= 3.11 and Orca 2.4.1 installed:

git clone https://github.com/antonio94770/Snapmaker-U1-Print-Copilot.git
cd Snapmaker-U1-Print-Copilot
git checkout aa73504769f591bb9c993c9b662de601251da4e6
python -m pip install -e .
python research/m4-probe/recheck_release.py C:/orca-cli-recheck

Use a fresh short absolute work directory that does not already exist. The script copies bundled presets and does not modify the installation or user presets or communicate with a printer. The suite includes intentional crash probes, each with a 45-second timeout. Commands use Windows-style paths and four filament presets.

Checklist of files to include

  • [ ] Raw log file attached (preserved locally by the script)
  • [x] Reproducer and input-generation code linked above

antonio94770 avatar Oct 29 '26 13:10 antonio94770

Root cause confirmed in the v2.4.1 source: normalize_fdm() dereferences nozzle_diameter when the config has wipe_tower_filament, but nozzle_diameter is a machine option absent from a bare process preset, so opt() returns null and ->size() crashes (0xC0000005). Every stock U1 process preset has wipe_tower_filament and no nozzle_diameter.

Fix: null-check nozzle_diameter before the range check; when absent, skip the check instead of dereferencing null.

PR: https://github.com/Snapmaker/OrcaSlicer/pull/1187

creat3dworld avatar Nov 14 '26 05:11 creat3dworld

Update: this is already fixed on upstream main. In main's DynamicPrintConfig::normalize_fdm (src/libslic3r/PrintConfig.cpp), the wipe_tower_filament range check now guards the nozzle_diameter lookup with nozzles != nullptr and null-checks the filament option itself, with the comment "Partial presets may lack printer settings; defer the upper-bound check until they are merged." So a bare process preset without nozzle_diameter no longer crashes on main. I had opened PR #1187 with a v2.4.1-based patch for this, but it conflicts with main's fix, so I closed it as superseded. No action needed — the fix is already in main.

creat3dworld avatar Nov 14 '26 05:11 creat3dworld