vivier / qemu-m68k

Other
40 stars 6 forks source link

gcc-7 segfaulting trying to compile a simple C code #27

Closed glaubitz closed 6 years ago

glaubitz commented 6 years ago

With the latest revision of the m68k-dev branch, gcc-7 segfaults:

(sid-m68k-sbuild)root@nofan:/# gcc -o rrdtool-test rrdtool-test.c 
rrdtool-test.c:1:0: internal compiler error: Segmentation fault
 #include <stdio.h>

executable file is not ELF
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
(sid-m68k-sbuild)root@nofan:/#

This is clearly a regression since earlier revisions work fine.

vivier commented 6 years ago

The problem appears with:

commit 15fa08f8451babc88d733bd411d4c94976f9d0f8 Author: Richard Henderson richard.henderson@linaro.org Date: Thu Nov 2 15:19:14 2017 +0100

tcg: Dynamically allocate TCGOps

With no fixed array allocation, we can't overflow a buffer.
This will be important as optimizations related to host vectors
may expand the number of ops used.

Use QTAILQ to link the ops together.

As we have no limit anymore on the size of TCGOps cache we can overflow the TCG temp variable array.

vivier commented 6 years ago

Fixed by:

commit f9bfde46b2f1bc0099eaa2b8afef793a3d115364 Author: Laurent Vivier laurent@vivier.eu Date: Fri Feb 16 12:19:36 2018 +0100

m68k: Test if we overflow the temp variable array

Since commit 15fa08f845 ("tcg: Dynamically allocate TCGOps")
we have no limit to fill the TCGOps cache and we can fill
the entire TCG variables array and overflow it.

To avoid that, we stop the translation when the array is close to
be full.
glaubitz commented 6 years ago

Yes, I can confirm this is fixed. However, the new version still regresses GHC which previously worked fine.