[BUG] poweroff command in ./u-boot -T -l causes SIG_SEGV

Mark Kettenis mark.kettenis at xs4all.nl
Sat Oct 22 14:19:46 CEST 2022


> Date: Sat, 22 Oct 2022 11:14:34 +0200
> From: Heinrich Schuchardt <xypron.glpk at gmx.de>
> 
> Hello Simon,
> 
> when running ./u-boot -T -l and issuing the poweroff command a crash occurs:
> 
> os_exit() results in std::ostream::flush() calling U-Boot's fflush with
> file = -138447008 (or any other negative number)
> 
> Man fflush shows the following definition:
> 
>      int fflush(FILE *stream);
> 
> U-Boot's fflush() is defined as
> 
>      void fflush(int file);
> 
> The pointer FILE *stream is truncated to int which may result in a
> negative number when invoking U-Boot's fflush() but anyway we want
> std::ostream::flush() to invoke glibc's fflush().
> 
> Can we ensure correct linking or do we have to rename fflush()?

Probably have to rename it.  The name is reserved by the ISO C
standard, at least when building in a non-freestanding environment.
And the sandbox stuff means that U-Boot isn't always compiled in a
free-standing environment.

I do wonder though how you end up building the sandbox with a C++
compiler.  There is some logic in the build system (inherited from the
Linux kernel?) to build host tools with C++.  But I'd hope the sandbox
doesn't use that.


More information about the U-Boot mailing list