vivier / qemu-m68k

Other
40 stars 6 forks source link

qemu-m68k/tcg/tcg.c:1774: tcg fatal error (temp_load():TEMP_VAL_DEAD:abort()) #6

Closed trofi closed 8 years ago

trofi commented 8 years ago

When tried to look at GHC to m68k (https://ghc.haskell.org/trac/ghc/ticket/11395) I've got to a state where qemu-m68k fails to execute C-compiled code with an internal error. Here is the selfcontained example that can crash qemu:

# m68k.S:
#  build as:
#    m68k-unknown-linux-gnu-gcc -nostdlib -nostartfiles m68k.S -o foo
#  run as:
#    qemu-m68k -d unimp,guest_errors,in_asm -L /usr/m68k-unknown-linux-gnu/ foo
#
#  fails as:
#    IN:
#    0x80000054:  asll #2,%d0
#    0x80000056:  movel %a0@-,%d2
#    0x80000058:  rts
#    qemu-m68k/tcg/tcg.c:1774: tcg fatal error
_start:
  asll #2,%d0
  movel %a0@-,%d2
  rts

AFAIU this should not cause qemu fail to translate.

(for completeness) The real-world crash trace looks like that:

$ qemu-m68k-git -d unimp,guest_errors,in_asm -L /usr/m68k-unknown-linux-gnu/ /tmp/mul2
----------------
IN: 
0xf550c812:  moveq #32,%d5
0xf550c814:  subl %d4,%d5
0xf550c816:  movel %d6,%d0
0xf550c818:  asll #2,%d0
0xf550c81a:  addal %d0,%a0
0xf550c81c:  addal %d0,%a1
0xf550c81e:  movel %a0@-,%d2
0xf550c820:  movel %d2,%d0
0xf550c822:  lsrl %d5,%d0
0xf550c824:  lsll %d4,%d2
0xf550c826:  movel %d2,%d1
0xf550c828:  subql #1,%d6
0xf550c82a:  beqs 0xf550c856

qemu-m68k/tcg/tcg.c:1774: tcg fatal error
vivier commented 8 years ago

Strangely, to have an unused temp register triggers this problem.

Try this, please:

temp_free.patch

trofi commented 8 years ago

The patch seemingly helps to get past the offending instruction. Thank you!

trofi commented 8 years ago

Closing pull request as 03d386a fixes uninit register use.

Thanks!