This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Program that segfaults with -Ofast


On 05.01.2018 11:57, Mason wrote:
On 04/01/2018 17:51, Christer Solskogen wrote:

Probably because it's about amiberry, which is a uae4arm-rpi fork.
And because O3/Ofast probably does some magic.

(IMO, -Ofast is an "unsafe" optimization level: "It enables optimizations
that are not valid for all standard-compliant programs.")


I'm not sure why the developer chose that. It was not my decision.
Could you run the crashing binary under valgrind?
Do you get interesting results?


==7821== Conditional jump or move depends on uninitialised value(s)
==7821==    at 0x29478C: read_kickstart (memory.cpp:581)
==7821== by 0x29478C: read_kickstart_version(uae_prefs*) (memory.cpp:1151)
==7821==    by 0x28E243: fixup_prefs(uae_prefs*, bool) (main.cpp:195)
==7821== by 0x1AB34F: cfgfile_load(uae_prefs*, char const*, int*, int, int) (cfgfile.cpp:3969) ==7821== by 0x2F593B: target_cfgfile_load(uae_prefs*, char const*, int, int) (amiberry.cpp:527)
==7821==    by 0x28F927: parse_cmdline_and_init_file (main.cpp:608)
==7821==    by 0x28F927: real_main2 (main.cpp:686)
==7821==    by 0x28F927: real_main(int, char**) (main.cpp:784)
==7821==    by 0x151D97: main (amiberry.cpp:920)
==7821==
==7821== Conditional jump or move depends on uninitialised value(s)
==7821==    at 0x29479C: read_kickstart (memory.cpp:584)
==7821== by 0x29479C: read_kickstart_version(uae_prefs*) (memory.cpp:1151)
==7821==    by 0x28E243: fixup_prefs(uae_prefs*, bool) (main.cpp:195)
==7821== by 0x1AB34F: cfgfile_load(uae_prefs*, char const*, int*, int, int) (cfgfile.cpp:3969) ==7821== by 0x2F593B: target_cfgfile_load(uae_prefs*, char const*, int, int) (amiberry.cpp:527)
==7821==    by 0x28F927: parse_cmdline_and_init_file (main.cpp:608)
==7821==    by 0x28F927: real_main2 (main.cpp:686)
==7821==    by 0x28F927: real_main(int, char**) (main.cpp:784)
==7821==    by 0x151D97: main (amiberry.cpp:920)
==7821==
==7821== Invalid read of size 4
==7821==    at 0x28E2AC: fixup_prefs(uae_prefs*, bool) (main.cpp:207)
==7821== by 0x1AB34F: cfgfile_load(uae_prefs*, char const*, int*, int, int) (cfgfile.cpp:3969) ==7821== by 0x2F593B: target_cfgfile_load(uae_prefs*, char const*, int, int) (amiberry.cpp:527)
==7821==    by 0x28F927: parse_cmdline_and_init_file (main.cpp:608)
==7821==    by 0x28F927: real_main2 (main.cpp:686)
==7821==    by 0x28F927: real_main(int, char**) (main.cpp:784)
==7821==    by 0x151D97: main (amiberry.cpp:920)
==7821==  Address 0x29bb8 is not stack'd, malloc'd or (recently) free'd



I cloned the repo, and looked at src/memory.cpp
read_kickstart() is static, and is never called through a function pointer.


Ok. I really don't know what that means, and if it's a good or a bad thing. I have some knowledge about C, and very little (close to nothing) about C++.


$ git grep -n read_kickstart
src/memory.cpp:424:static int read_kickstart (struct zfile *f, uae_u8 *mem, int size, int dochecksum, int noalias)
src/memory.cpp:540:      read_kickstart (f, extendedkickmem_bank.baseaddr, extendedkickmem_bank.allocated, 0, 1);
src/memory.cpp:613:     read_kickstart (f, extendedkickmem_bank.baseaddr, ROM_SIZE_512, 0, 1);
src/memory.cpp:617:     read_kickstart (f, kickmem_bank.baseaddr, ROM_SIZE_512, 1, 0);
src/memory.cpp:679:       size = read_kickstart (f, kickmem_bank.baseaddr, maxsize, 1, 0);
src/memory.cpp:690:         read_kickstart (f, extendedkickmem_bank.baseaddr, extendedkickmem_bank.allocated, 0, 1);
src/memory.cpp:697:         read_kickstart (f, extendedkickmem2_bank.baseaddr, ROM_SIZE_512, 0, 1);
src/memory.cpp:699:         read_kickstart (f, extendedkickmem2_bank.baseaddr + ROM_SIZE_512, ROM_SIZE_512, 0, 1);

What is weird is that every call to read_kickstart() has the 'size' argument
either ROM_SIZE_512, or ROM_SIZE_256, or ROM_SIZE_512 * 2. It's never 32 like
in the sanitizer's stack dump...


Is that something that O3/Ofast can do?

--
chs


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]