vivier / qemu-m68k

Other
40 stars 6 forks source link

Rare random parse errors when building Haskell code #21

Closed glaubitz closed 6 years ago

glaubitz commented 7 years ago

This is another issue which will be hard to track down. The fix from 843cd25f2747f9a4a51c6af3442fd97c5fd25ea3 already brought lots of improvement, so that many Haskell packages build now fine. But there are still some occasional hickups [1]:

[ 6 of 27] Compiling UU.Pretty        ( src/UU/Pretty.hs, dist-ghc/build/UU/Pretty.o )
[ 7 of 27] Compiling UU.PPrint        ( src/UU/PPrint.hs, dist-ghc/build/UU/PPrint.o )

src/UU/PPrint.hs:371:25: error: parse error on input `Union'
/usr/share/cdbs/1/class/hlibrary.mk:147: recipe for target 'build-ghc-stamp' failed
make: *** [build-ghc-stamp] Error 1
dpkg-buildpackage: error: debian/rules build-arch gave error exit status 2

The problem with this one is that it's not easily reproducible but it does occur. As already mentioned in #20, maybe we need to add the fix from e9f4459f0f23c790b3e5320c6743768f5affcc4d for the other CAS instructions as well?

[1] https://buildd.debian.org/status/fetch.php?pkg=haskell-uulib&arch=m68k&ver=0.9.20-4&stamp=1482707292

glaubitz commented 7 years ago

Another observation: When this issue occurs, it's usually enough to just run make again and the build continues fine.

vivier commented 7 years ago

It really looks like a race condition. If I run a loop with ghc I can reproduce it and the error is not always the same:

while ghc -v -c -o dist-ghc/build/UU/PPrint.o src/UU/PPrint.hs ; do
  rm dist-ghc/build/UU/PPrint.o;
done
src/UU/PPrint.hs:90:46: error: parse error on input `ds'

or

 src/UU/PPrint.hs:291:17: error: parse error on input `)'

or

 Inconsistency detected by ld.so: dl-lookup.c: 844: _dl_lookup_symbol_x: Assertion `version != NULL' failed!

And if I add traces, I can't reproduce it.

glaubitz commented 7 years ago

Ah, nice. I was just working to create minimal use case.

glaubitz commented 7 years ago

This issue does not show when running qemu-m68k in system mode from the q800-dev branch.

So this pretty much looks like a multi-threading issue. @karcherm already suggested that this might be an endianness issue when passing futex values from the big-endian guest userspace to the little-endian kernel.

Unfortunately, I have not been able to verify this theory due to the problems on big-endian hosts (see #17).

glaubitz commented 6 years ago

I can no longer reproduce this issue. All Haskell packages, including GHC now build fine for me on qemu-m68k in QEMU user mode.