Avoid null pointer dereference for partial configuration settings #13885
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #13864.
I first looked at how other extruder configuration options were validated and/or normalized. I found them at:
PrusaSlicer/src/libslic3r/PrintObject.cpp
Lines 2598 to 2599 in 5c7888b
and:
PrusaSlicer/src/libslic3r/PrintObject.cpp
Lines 2650 to 2652 in 5c7888b
Upon further analysis, I determined that
wipe_tower_extruder
validation does not really fit in either spot -- as far as I can tell, thewipe_tower_extruder
can only be set at the print level, whereas the others can be set for individual objects (for supports) or even regions of an object (for the rest).I considered adding another call of
clamp_exturder_to_default
[sic] in several other locations, such as withinPrint::validate(std::vector<std::string>*)
orPrint::apply(const Model &, DynamicPrintConfig)
. Quite possibly one of these spots could have worked, however due to my unfamiliarity with the code base, I was concerned that I may accidentally introduce other bugs. I also felt a large amount of testing would be required to validate such a change. For instance, I was not sure at what point it is no longer safe to change configuration (i.e. updatingwipe_tower_extruder
to a valid value) due to other logic already relying on it.After a lot of deliberation, it seemed to me that
DynamicPrintConfig::normalize_fdm()
could work after all (despite my initial concerns expressed in #13864). I examined where it is called, and I found it is used in several stages of processing configuration -- for example, for each file provided by a--load
command line option, for presets, for default FFF or SLA print options, and so on.Even though early calls to
DynamicPrintConfig::normalize_fdm()
do not necessarily have full configuration (i.e. the original bug), for sure later calls do. And it seemed to me that someone had already testedwipe_tower_extruder
validation at this location (just not withoutnozzle_diameter
in the same file) to prove that this could work.I did build this and do some very basic testing (a few command line calls, including what I was originally doing when I encountered the segmentation fault in the first place).