3 ms·
UB can easily wipe "the drive" on my microcontroller by sending a wrong SPI command to the flash chip, or by messing with write unprotected memory mapped built
by AstralStorm 4y ago
UB can easily wipe "the drive" on my microcontroller by sending a wrong SPI command to the flash chip, or by messing with write unprotected memory mapped built in flash.
Welcome to kernel code. I believe one could make it play DOOM by clever malice in this case.
- nmilo 4y agoYeah, I never said it couldn't, I said the more helpful thing to say is that UB can cause what looks like dead code to not be dead. If that dead code includes, an rm -rf, or, say, a function to enable/disable arbitrary pins on your chip, then yes, that dead code might be called, and with undefined parameters too. But saying UB will wipe your drive is just misleading and almost wrong.
- account42 4y agoWe need a doomcc that will replace all undefined behavior with doom. A more fun version of ubsan if you will.
- nayuki 4y agoThanks for inadvertently realizing my prediction. > When a C or C++ program triggers undefined behavior, anything is allowed to happen in the program execution. And by anything, I really mean anything: The program can crash with an error message, it can silently corrupt data, it can morph into a colorful video game, or it can even give the right result. -- https://www.nayuki.io/page/undefined-behavior-in-c-and-cplusplus-programs https://www.nayuki.io/page/undefined-behavior-in-c-and-cplus...