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 SD card handling when rapid-firing 'c' #323

Closed wavexx closed 3 years ago

wavexx commented 3 years ago

Describe the bug MK404 crashes when holding 'c' (mount/unmount SD card)

To Reproduce

#0  0x000055a3b50c6486 in SDCard::OnSPIIn(avr_irq_t*, unsigned int) ()
[Current thread is 1 (Thread 0x7f1cb66fc700 (LWP 171312))]
(gdb) where
#0  0x000055a3b50c6486 in SDCard::OnSPIIn(avr_irq_t*, unsigned int) ()
#1  0x000055a3b50e95f8 in SPIPeripheral::OnPostInit(avr_t*, unsigned int)::{lambda(avr_irq_t*, unsigned int, void*)#1}::_FUN(avr_irq_t*, unsigned int, void*) [clone .lto_priv.0] ()
#2  0x000055a3b5115574 in avr_raise_irq_float ()
#3  0x000055a3b51163e7 in avr_spi_raise ()
#4  0x000055a3b510f9e7 in avr_cycle_timer_process ()
#5  0x000055a3b5104e3c in avr_callback_run_raw ()
#6  0x000055a3b50acbf0 in Boards::Board::RunAVR() ()

Expected behavior No crash, I suppose :)

Screenshots

Desktop (please complete the following information):

Additional context Not a critical problem, as you can imagine :)

vintagepc commented 3 years ago

Good find, this is a nasty one.

Looks like we forgot to guard against the memory-mapped data "going away" in the middle of a block read:

image

wavexx commented 3 years ago

I had to laugh at the "let's never speak of this again" label :P