vintagepc / MK404

A functional Simulator for Prusa (Mini/Einsy) Rambo based printers
https://vintagepc.github.io/MK404/
GNU General Public License v3.0
72 stars 9 forks source link

[BUG] Crash on PINDA when probing outside the bed range #313

Closed wavexx closed 3 years ago

wavexx commented 3 years ago

Describe the bug Attempt to perform MBL on a MK2.5S results in a crash:

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7798537 in __GI_abort () at abort.c:79
#2  0x00007ffff7b327ec in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff7b3d966 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff7b3d9d1 in std::terminate() () from /lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x000055555558db37 in gsl::detail::fail_fast_terminate () at /home/ydelia/prusa/MK404/3rdParty/gsl/gsl-lite.hpp:1272
#6  0x00005555555be7e3 in gsl::at<float, 49ul> (arr=..., pos=255) at /home/ydelia/prusa/MK404/3rdParty/gsl/gsl-lite.hpp:1735
#7  0x00005555555bd090 in PINDA::CheckTrigger (this=0x555555798790) at /home/ydelia/prusa/MK404/parts/components/PINDA.cpp:136
#8  0x00005555555bd255 in PINDA::OnZChanged (this=0x555555798790, value=1086324736) at /home/ydelia/prusa/MK404/parts/components/PINDA.cpp:227

The calculated iX is 255, because the m_fOffset[0] = 25, m_fPos[0] = 10, so it results in a negative number. Note that this is happening while homing, not during MBL.

Maybe the XY offset is not entirely correct at that point? There's a good argument that PINDA shouldn't trigger when far away from the bed (although it should still work within a ~5mm boundary), but it shouldn't crash.

To Reproduce Start with a MK2.5S FW, perform G28.

Expected behavior No crash.