Fix "Access Violation" (#12704)#12856
Conversation
Cube.3mf contains custom printer G-code with literal T10 commands in machine_end_gcode Orca parses that T10, correctly recognizes it as invalid because 10 >= m_result.filaments_count, but then still calls process_filament_change(10). So the access violation is not caused by the 3MF being broken. It is caused by:
Same behavior can be observed with M1020 command also: I would fix it like this: or |
|
I'll try it as soon as I can, Thanks! |
@kisslorand it works, you are right. |
f90e268 to
34b6d27
Compare
Shouldn't we raise a proper error message saying something like "invalid T10 command" instead of silently ignoring it? |
But in that case, an error message would pop up for every slice in that machine profile – wouldn't that be rather annoying? |
Then maybe fix that profile? Unless a "T10" is required for that printer to function properly, otherwise it just doesn't make sence to me. |
|
|
I see. That's kinda annoying but I guess we have to live with that then. |
Adding a warning notification is dangerous: one may think that the profile is broken and try to "fix" it themselves by removing unknown Gcode commands. Which may cause damage to the printer during the execution process. If we need a warning anyways, I'd prefer it to be displayed under the gcode section when you edit printer gcode. |
In the current implementation, it saves it in the log. |
|
Yeah if it's required for that printer to work, then we should not warn the user to avoid any confusion. |
Added an assertion to validate filament ID before processing.
Add early returns in process_M1020 and process_T when the parsed extruder/filament id is out of range to avoid calling process_filament_change with an invalid index (also add braces for clarity). Remove a redundant runtime bounds check in process_filament_change, leaving the existing assert as the intended safeguard in debug builds. This prevents potential invalid access while keeping error logging for malformed commands. Co-Authored-By: Kiss Lorand <[email protected]>
34b6d27 to
1cdb280
Compare

Description
Add early returns in process_M1020 and process_T when the parsed extruder/filament id is out of range to avoid calling process_filament_change with an invalid index.
Screenshots/Recordings/Graphs
Tests
Cube.zip
Fix #12704
Related to #12684