Backtrace without stripping the executable:

(gdb) bt
#0  0x0000000000000001 in ?? ()
#1  0x000000000046bd30 in mz80exec (dwCycles=<value optimized out>)
    at zz80.c:14960
#2  0x000000000040458f in md::one_frame_musa (this=0x7fff6af1c580,
    bm=0x6b8a00, retpal=0x0, sndi=0x6b8a20) at mdfr.cpp:168
#3  0x000000000040d2fe in main (argc=<value optimized out>,
    argv=<value optimized out>) at main.cpp:465

Looking at that line, it is expecting to find a 0xffffffff marker at the
end of a list, which is somewhere else set to (UINT32)-1. The problem is
that UINT32 is #defined to "unsigned long int", which is 64 bits on
x86-64, and thus the marker ends up as 0xffffffffffffffff.

A simple fix is to use <stdint.h> for the correct types. This exposes
the next problem (which gcc helpfully warns about when attempting to
compile): in several places it uses "(UINT32) pbPC - (UINT32)
cpu.z80Base", where pbPC and z80Base are pointers. "(UINT32) (pbPC -
cpu.z80Base)" is a portable alternative, which should always have the
same result, even on 32-bit (assuming pbPC points to within z80Base,
which it should do for the subtraction to make sense).

Running the code with these fixes crashes elsewhere (looks like MZ80
wasn't that 64-bit unclean after all); however, at the new crash site
there are no helpful defines to help us this time, and untangling the
correct sizes of the types will take some more time.

(gdb) bt
#0  0x00000000004088b0 in md_vdp::draw_plane_back1 (this=0x7fffd3281970,
    line=<value optimized out>) at ras.cpp:466
#1  0x000000000040caca in md_vdp::draw_scanline (this=0x7fffd3281970,
    bits=<value optimized out>, line=17) at ras.cpp:752
#2  0x0000000000404606 in md::one_frame_musa (this=0x7fffd3281930,
    bm=0x6b7860, retpal=0x0, sndi=0x6b7880) at mdfr.cpp:277
#3  0x000000000040d2ee in main (argc=<value optimized out>,
    argv=<value optimized out>) at main.cpp:465

The code at that point also doesn't seem to be -fstrict-aliasing safe (a
simple workaround would be to add -fno-strict-aliasing).

Attached is a patch with the changes I've made so far. I might try to
fix it further at some later time.

** Attachment added: "Patch to make MZ80 64-bit clean"
   http://launchpadlibrarian.net/10807825/mz80-stdint.patch

-- 
dgen crashed with SIGSEGV in __libc_start_main()
https://bugs.launchpad.net/bugs/131281
You received this bug notification because you are a member of Ubuntu
Bugs, which is the bug contact for Ubuntu.

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to