critterandguitari / Organelle_OS

Other
57 stars 24 forks source link

Crash when compiled with optimisation #41

Closed ssssam closed 3 years ago

ssssam commented 3 years ago

Note: this isn't a support request, I am reporting the issue just in case it's useful :)

The mother program built for Organelle 1 crashes when compiled with GCC -Os, -O1 and -O2 flag. Tested with GCC 8.4.0 and 9.3.0 (from https://toolchains.bootlin.com/releases_armv7-eabihf.html). Building with no optimisation flags works around the issue.

The crash is here as reported by Valgrind:

# valgrind /root/mother 
==646== Memcheck, a memory error detector
==646== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==646== Using Valgrind-3.17.0 and LibVEX; rerun with -h for copyright info
==646== Command: /root/mother
==646== 
opening serial .....
opened serial, setting up... 
done opening serial 
Using FW DIR: /root/fw_dir
build date Aug  4 2021   18:50:18/nscandir patchlist
patch[0] 
patch[1] Shutdown
patch[2] Storage
patch[3] Settings
patch[4] Extra
patch[5] 
num patches 0
patch menu offset 6
opening serial .....
==646== Invalid write of size 4
==646==    at 0x1C964: Serial::Serial() (in /root/mother)
==646==    by 0x1C93F: SLIPEncodedSerial::sendMessage(unsigned char const*, unsigned int, Serial&) (in /root/mother)
==646==    by 0x1EB23: SerialMCU::init() (in /root/mother)
==646==  Address 0x12 is not stack'd, malloc'd or (recently) free'd
==646== 
==646== 
==646== Process terminating with default action of signal 11 (SIGSEGV)
ssssam commented 3 years ago

Fixed by https://github.com/critterandguitari/Organelle_OS/pull/42