Re: [hatari-devel] Hatari segfault on cold boot with MMU + EmuTOS |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
Hi,
On 11/1/18 11:48 PM, Nicolas Pomarède wrote:
Le 01/11/2018 à 19:00, Nicolas Pomarède a écrit :
Le 01/11/2018 à 11:02, Nicolas Pomarède a écrit :
I have an other PC which is still running linux 32 bit, I will try on
it too.
good news is that I can duplicate the crash when using a 32 bit build.
Good.
With your latest update (which shouldn't affect this as I'm not using
TT-RAM), I'm not anymore able to reproduce the crash right after EmuTOS
bootup screen. I get it only when pressing AltGr+C *after* EmuDesk
desktop has come up.
This looks like some memory being overwritten at some points, because
when I add some debug printf, some of those printfs make the crash
disappear ...
So far, I see that the crash happens just after the reset, the 1st
instruction after the reset get a bus error when being fetched.
I think it's a bug in hatari, because PC is not the correct value at
this point, so when mmu is on, this calls mmu030_page_fault() and this
is more or less where the crash happens (I still need to add more
traces to see what part of the code can trigger the bus error).
But I think the source of the bug is in Hatari, not in WinUAE.
Additional note : it seems the crash happens when some optimisations are
enabled. cmake defaults will be -O3, but if I run "./configure
--enable-debug" and modify the debug section in CMakeList.txt to use
"-O0" instead of "-O", then I'm not able to crash hatari anymore.
This really confirms that some memory must be leaking somewhere and its
impact/crash will depend on what region get overwritten.
-O0 keeps all variables in stack instead of using registers for them,
and doesn't do *any* other optimizations either, so the stack content
can be really different with it, than when optimizations are enabled.
It seems that GCC enables strict aliasing now even with -O2 & -Os.
Aliasing is one of the ways where code can shoot itself, but I don't
get any warnings with -Wstrict-aliasing (which should catch most, but
not all of potential issues).
Enabling -Wextra, complains just about missing field initializers
and things that might get clobbered by longjmp or vfork. -Wshadow
complains mostly about very common names used by WinUAE core.
Of last one, the ones related to MMU use are:
-------------------------------------
hatari/src/cpu/memory.c: In function ‘memory_map_Standard_RAM’:
hatari/src/cpu/memory.c:1506:39: warning: declaration of
‘MMU_Bank0_Size’ shadows a global declaration [-Wshadow]
void memory_map_Standard_RAM ( Uint32 MMU_Bank0_Size , Uint32
MMU_Bank1_Size )
^~~~~~~~~~~~~~
In file included from hatari/src/includes/ioMem.h:20:0,
from hatari/src/cpu/memory.c:24:
hatari/src/includes/stMemory.h:40:15: note: shadowed declaration is here
extern Uint32 MMU_Bank0_Size;
^~~~~~~~~~~~~~
hatari/src/cpu/memory.c:1506:63: warning: declaration of
‘MMU_Bank1_Size’ shadows a global declaration [-Wshadow]
void memory_map_Standard_RAM ( Uint32 MMU_Bank0_Size , Uint32
MMU_Bank1_Size )
^~~~~~~~~~~~~~
In file included from hatari/src/includes/ioMem.h:20:0,
from hatari/src/cpu/memory.c:24:
hatari/src/includes/stMemory.h:41:15: note: shadowed declaration is here
extern Uint32 MMU_Bank1_Size;
^~~~~~~~~~~~~~
-------------------------------------
This looks also a bit suspect:
-------------------------------------
hatari/src/cpu/build68k.c: In function ‘main’:
hatari/src/cpu/build68k.c:83:19: warning: declaration of ‘flaguse’
shadows a global declaration [-Wshadow]
int flagset[5], flaguse[5];
^~~~~~~
In file included from hatari/src/cpu/build68k.c:10:0:
hatari/src/cpu/readcpu.h:62:13: note: shadowed declaration is here
} ENUMNAME (flaguse);
^
hatari/src/cpu/sysdeps.h:274:24: note: in definition of macro ‘ENUMNAME’
#define ENUMNAME(name) name
^~~~
-------------------------------------
- Eero