On Mon, 8 Oct 2018 at 21:00, Josef Wolf wrote: > > On Sat, Oct 06, 2018 at 11:51:33AM +0800, Xi Ruoyao wrote: > > > Simply crashing leaves you without any clue. You have no idea where to look > > > for the bug. The crash could even be by a power outage. That's not exactly > > > improving the situation. > > > > You have GDB. > > I'd happily do this. But unfortunately, this is an embedded system, and it > doesn't have a debug interface. > > So gdb won't help very much here. > > > > Issuing a diagnostic "Oops, NULL-dereference at adsf.c:123" would improve > > > the situation: you know where to look for the fix. > > > > You have -fsanitize=undefined. > > Ah! This seems to be exactly what I was looking for! > > Unfortunatly, the linker complains that it can't find -lubsan. You can use -fsanitize-undefined-trap-on-error to avoid the need for libubsan by inserting traps instead of calls to libubsan, but then you're back where you started. > Do I need to do something special to enable the build/install of the sanitizer > runtime library on an embedded target? AFAICS, the sanitizer should be built > by default? I don't think libubsan is built for all targets.