-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Memory Access problem, solveable by additional sanity check #23980
Comments
you may try with: |
this kind of check is also done outside sanitycheck.h, for some other arrays |
I just saw now that SWITCHING_TOOLHEAD_X_POS array is also used in other parts of code. Maybe it's better to really add this somewhere to sanitycheck.h: #if ANY(SWITCHING_TOOLHEAD, MAGNETIC_SWITCHING_TOOLHEAD, ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
constexpr float thpx[] = SWITCHING_TOOLHEAD_X_POS;
static_assert(COUNT(thpx) == EXTRUDERS, "SWITCHING_TOOLHEAD_X_POS must be an array EXTRUDERS long.");
#endif |
Closing since a PR was created: #23985 |
thanks a bunch! |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Did you test the latest
bugfix-2.0.x
code?No, but I will test it now!
Bug Description
There exists no validation for the array size of "SWITCHING_TOOLHEAD_X_POS" in Configuration.h.
With more than two toolheads, this can lead to a memory access problem in tool_change.cpp, line 507 "grabxpos = toolheadposx[new_tool];"
It will query a "random" x position for a toolhead whose index is larger than the array size from configuration.h.
I am not super familiar with the way the sanity checks are done, so am sadly disabled to add a appropriate sanity check myself.
Additionally, Software endstops were enabled, and not regarded during toolhead changes. Which might or might not be on purpose, depending if the parking locations are supposed to be in "printable" area or not by definition.
Bug Timeline
No response
Expected behavior
Toolhead E3 does not crash into x boundaries, especially with software endstops enabled
Actual behavior
With software endstops enabled, changing the toolhead should not cause the toolhead to move to a "random" x position outside of software endstop limits.
During compiletime, it should be checked if there exists a defined parking position for each of the toolheads.
Steps to Reproduce
No response
Version of Marlin Firmware
2.0.9.3
Printer model
similar e3d toolchanger system, corexy, 3 toolheads
Electronics
BOARD_BTT_OCTOPUS_V1_1
Add-ons
No response
Bed Leveling
ABL Bilinear mesh
Your Slicer
No response
Host Software
No response
Additional information & file uploads
No response
The text was updated successfully, but these errors were encountered: