Files
OrcaSlicer/tests/data/wipe_tower_temperature_trace_main.txt
SoftFever 3b445905d1 Fix out-of-bounds reads in the multi-extruder flush-volume matrix
flush_volumes_matrix stores one (filaments x filaments) block per nozzle,
but set_extruder, WipeTower2::extract_wipe_volumes and the PresetBundle
rebuild indexed each block with filament_colour.size() as the row stride.
When the stored matrix does not match that assumption (a legacy project, or
a just-switched printer -- e.g. a single 2x2 block while nozzle_diameter has
2 entries) the index runs past the sliced block and reads out of bounds.

The read is undefined, so its value depends on the C++ std-lib/allocator
layout: identical across Linux architectures but different on macOS/Windows.
That surfaced as the "Toolchange temperature commands are unchanged when the
wipe tower wait is off" regression failing on Linux CI while passing on
macOS/Windows, and crashing hardened (-O0, _GLIBCXX_ASSERTIONS) builds.

- Centralize the block-dimension derivation in get_flush_volumes_matrix_dims
  (sqrt(size / nozzles) with a filaments^2 * nozzles == size check and a
  single-block fallback) and use it wherever the matrix is sliced/indexed;
  bounds-guard the reads as defense in depth. It weighs both options that
  claim to say how many blocks are stored, since either can be stale:
  flush_multiplier, written with the matrix in the project config, and
  nozzle_diameter, which changes the moment a printer is selected.
- PresetBundle::update_multi_material_filament_presets: rebuild the matrix on
  a nozzle-count-only change too (the old per-block gate missed those), and
  seed a brand-new nozzle from the first nozzle's tuned block.
- is_flush_config_modified: stride the stored matrix by its own dimension
  rather than the current filament count, and bound the nozzle loop by the
  printer's extruder count, which CalcFlushingVolumes indexes as well.
- is_flushing_matrix_error: the same derivation, which additionally divided
  by zero on an empty flush_multiplier.
- update_slice_warnings: guard nozzle_hrc_lists, which is sized by the
  nullable nozzle_type option and can be shorter than the extruder count.

With the read fixed the emitted trace is deterministic across builds and
platforms, so regenerate the golden from it and stop comparing the rounded
"time: <n>s" preheat comment (the tolerant lead time already carries that
timing). Add unit tests for the flush-matrix rebuild and dimension logic.
2026-08-07 14:21:26 +08:00

169 lines
6.3 KiB
Plaintext

# Temperature and tool-change commands of a wait_for_temp_on_wipe_tower-off slice,
# captured from main (18ca06ec6b) with the set_extruder flush-volume out-of-bounds fix applied.
# Regeneration is described
# at the test that reads this file: "Toolchange temperature commands are unchanged
# when the wipe tower wait is off" in tests/fff_print/test_multifilament.cpp.
M104 S215 T0 ; set nozzle temperature
M104 S215 T1 ; set nozzle temperature
; CP PRIMING START
T1 ; change extruder
M109 S215 T1 ; set nozzle temperature and wait for it to be reached
M104 S175 T1 ; set nozzle temperature ;cooldown
T0 ; change extruder
M109 S215 T0 ; set nozzle temperature and wait for it to be reached
; CP PRIMING END
M104 S215 T1 ; preheat T1 time: 30s lead 30.2s
; CP TOOLCHANGE START
M104 S175 T0 ; set nozzle temperature ;cooldown
T1 ; change extruder
M109 S215 T1 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T1 ; set nozzle temperature
M104 S240 T0 ; preheat T0 time: 30s lead 30.0s
; CP TOOLCHANGE START
M104 S200 T1 ; set nozzle temperature ;cooldown
T0 ; change extruder
M109 S240 T0 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T1 ; preheat T1 time: 30s lead 30.4s
; CP TOOLCHANGE START
M104 S200 T0 ; set nozzle temperature ;cooldown
T1 ; change extruder
M109 S240 T1 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T0 ; preheat T0 time: 30s lead 30.3s
; CP TOOLCHANGE START
M104 S200 T1 ; set nozzle temperature ;cooldown
T0 ; change extruder
M109 S240 T0 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T1 ; preheat T1 time: 30s lead 30.3s
; CP TOOLCHANGE START
M104 S200 T0 ; set nozzle temperature ;cooldown
T1 ; change extruder
M109 S240 T1 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T0 ; preheat T0 time: 30s lead 30.3s
; CP TOOLCHANGE START
M104 S200 T1 ; set nozzle temperature ;cooldown
T0 ; change extruder
M109 S240 T0 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T1 ; preheat T1 time: 30s lead 30.3s
; CP TOOLCHANGE START
M104 S200 T0 ; set nozzle temperature ;cooldown
T1 ; change extruder
M109 S240 T1 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T0 ; preheat T0 time: 30s lead 30.3s
; CP TOOLCHANGE START
M104 S200 T1 ; set nozzle temperature ;cooldown
T0 ; change extruder
M109 S240 T0 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T1 ; preheat T1 time: 30s lead 30.3s
; CP TOOLCHANGE START
M104 S200 T0 ; set nozzle temperature ;cooldown
T1 ; change extruder
M109 S240 T1 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T0 ; preheat T0 time: 30s lead 30.3s
; CP TOOLCHANGE START
M104 S200 T1 ; set nozzle temperature ;cooldown
T0 ; change extruder
M109 S240 T0 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T1 ; preheat T1 time: 30s lead 30.3s
; CP TOOLCHANGE START
M104 S200 T0 ; set nozzle temperature ;cooldown
T1 ; change extruder
M109 S240 T1 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T0 ; preheat T0 time: 30s lead 30.1s
; CP TOOLCHANGE START
M104 S200 T1 ; set nozzle temperature ;cooldown
T0 ; change extruder
M109 S240 T0 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T1 ; preheat T1 time: 31s lead 30.6s
; CP TOOLCHANGE START
M104 S200 T0 ; set nozzle temperature ;cooldown
T1 ; change extruder
M109 S240 T1 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T0 ; preheat T0 time: 30s lead 30.3s
; CP TOOLCHANGE START
M104 S200 T1 ; set nozzle temperature ;cooldown
T0 ; change extruder
M109 S240 T0 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T1 ; preheat T1 time: 31s lead 30.5s
; CP TOOLCHANGE START
M104 S200 T0 ; set nozzle temperature ;cooldown
T1 ; change extruder
M109 S240 T1 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T0 ; preheat T0 time: 30s lead 30.2s
; CP TOOLCHANGE START
M104 S200 T1 ; set nozzle temperature ;cooldown
T0 ; change extruder
M109 S240 T0 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T1 ; preheat T1 time: 30s lead 30.2s
; CP TOOLCHANGE START
M104 S200 T0 ; set nozzle temperature ;cooldown
T1 ; change extruder
M109 S240 T1 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T0 ; preheat T0 time: 30s lead 30.2s
; CP TOOLCHANGE START
M104 S200 T1 ; set nozzle temperature ;cooldown
T0 ; change extruder
M109 S240 T0 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T1 ; preheat T1 time: 30s lead 30.2s
; CP TOOLCHANGE START
M104 S200 T0 ; set nozzle temperature ;cooldown
T1 ; change extruder
M109 S240 T1 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T0 ; preheat T0 time: 30s lead 30.2s
; CP TOOLCHANGE START
M104 S200 T1 ; set nozzle temperature ;cooldown
T0 ; change extruder
M109 S240 T0 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T1 ; preheat T1 time: 31s lead 30.6s
; CP TOOLCHANGE START
M104 S200 T0 ; set nozzle temperature ;cooldown
T1 ; change extruder
M109 S240 T1 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T0 ; preheat T0 time: 30s lead 30.4s
; CP TOOLCHANGE START
M104 S200 T1 ; set nozzle temperature ;cooldown
T0 ; change extruder
M109 S240 T0 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T1 ; preheat T1 time: 30s lead 30.4s
; CP TOOLCHANGE START
M104 S200 T0 ; set nozzle temperature ;cooldown
T1 ; change extruder
M109 S240 T1 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T0 ; preheat T0 time: 30s lead 30.0s
; CP TOOLCHANGE START
M104 S200 T1 ; set nozzle temperature ;cooldown
T0 ; change extruder
M109 S240 T0 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
M104 S240 T1 ; preheat T1 time: 30s lead 30.0s
; CP TOOLCHANGE START
M104 S200 T0 ; set nozzle temperature ;cooldown
T1 ; change extruder
M109 S240 T1 ; set nozzle temperature and wait for it to be reached
; CP TOOLCHANGE END
; CP TOOLCHANGE START
; CP TOOLCHANGE END
M104 S0 ; turn off temperature