vivier / qemu-m68k

Other
40 stars 6 forks source link

btyacc on qemu-m68k misbehaves if compiled with -O2 #13

Closed glaubitz closed 7 years ago

glaubitz commented 8 years ago

So, this is a rather obfuscated and weird bug, but there is definitely something wrong in qemu-m68k.

The package firebird2.5 (after applying the platform support patch in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=828141#10) currently fails to build from source on qemu-m68k but not on Aranym due to btyacc - which is embedded in the firebird2.5 sources - generating incorrect output. However, this happens only when compiling btyacc with "-O2". Compiling it without optimization does not trigger this problem.

Furthermore, the separate btyacc package in Debian - which was compiled a long time ago with an older version of gcc - does not show that behavior on qemu-m68k. The problem is triggered only when compiling btyacc with gcc-4.9 or newer (although we didn't test 4.7 or 4.8, but the working binary was compiled with a rather old gcc version, around gcc-4 or so). It does not matter whether btyacc is compiled on Aranym or qemu-m68k, but only whether -O2 is used or not. The -O2-built binary will always work correctly on Aranym and always misbehave on qemu-m68k.

Here is a detailed demonstration of the issue:

On Aranym:

root@mama:~# cd /tmp root@mama:/tmp# mkdir firebird2.5 root@mama:/tmp# cd firebird2.5/ root@mama:/tmp/firebird2.5# dget -u http://http.debian.net/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4-5.dsc dget: retrieving http://http.debian.net/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4-5.dsc --2016-07-05 18:11:31-- http://http.debian.net/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4-5.dsc Resolving http.debian.net (http.debian.net)... 128.31.0.66, 5.153.231.35, 2001:41c8:1000:21::21:35 Connecting to http.debian.net (http.debian.net)|128.31.0.66|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://ftp.fau.de/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4-5.dsc [following] --2016-07-05 18:11:31-- http://ftp.fau.de/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4-5.dsc Resolving ftp.fau.de (ftp.fau.de)... 131.188.12.211, 2001:638:a000:1021:21::1 Connecting to ftp.fau.de (ftp.fau.de)|131.188.12.211|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 3058 (3.0K) Saving to: ‘firebird2.5_2.5.5.26952.ds4-5.dsc’

firebird2.5_2.5.5.26952.ds4-5.dsc 100%[=========================================================================================================================================>] 2.99K --.-KB/s in 0s

2016-07-05 18:11:31 (17.9 MB/s) - ‘firebird2.5_2.5.5.26952.ds4-5.dsc’ saved [3058/3058]

dget: retrieving http://http.debian.net/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4.orig.tar.xz --2016-07-05 18:11:33-- http://http.debian.net/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4.orig.tar.xz Resolving http.debian.net (http.debian.net)... 128.31.0.66, 5.153.231.35, 2001:41c8:1000:21::21:35 Connecting to http.debian.net (http.debian.net)|128.31.0.66|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://ftp.fau.de/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4.orig.tar.xz [following] --2016-07-05 18:11:33-- http://ftp.fau.de/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4.orig.tar.xz Resolving ftp.fau.de (ftp.fau.de)... 131.188.12.211, 2001:638:a000:1021:21::1 Connecting to ftp.fau.de (ftp.fau.de)|131.188.12.211|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 4008160 (3.8M) [application/x-tar] Saving to: ‘firebird2.5_2.5.5.26952.ds4.orig.tar.xz’

firebird2.5_2.5.5.26952.ds4.orig.tar.xz 100%[=========================================================================================================================================>] 3.82M 976KB/s in 4.0s

2016-07-05 18:11:37 (988 KB/s) - ‘firebird2.5_2.5.5.26952.ds4.orig.tar.xz’ saved [4008160/4008160]

dget: retrieving http://http.debian.net/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4-5.debian.tar.xz --2016-07-05 18:11:39-- http://http.debian.net/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4-5.debian.tar.xz Resolving http.debian.net (http.debian.net)... 128.31.0.66, 5.153.231.35, 2001:41c8:1000:21::21:35 Connecting to http.debian.net (http.debian.net)|128.31.0.66|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://ftp.fau.de/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4-5.debian.tar.xz [following] --2016-07-05 18:11:39-- http://ftp.fau.de/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4-5.debian.tar.xz Resolving ftp.fau.de (ftp.fau.de)... 131.188.12.211, 2001:638:a000:1021:21::1 Connecting to ftp.fau.de (ftp.fau.de)|131.188.12.211|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 111316 (109K) [application/x-tar] Saving to: ‘firebird2.5_2.5.5.26952.ds4-5.debian.tar.xz’

firebird2.5_2.5.5.26952.ds4-5.debian.tar.xz 100%[=========================================================================================================================================>] 108.71K --.-KB/s in 0.1s

2016-07-05 18:11:39 (1.07 MB/s) - ‘firebird2.5_2.5.5.26952.ds4-5.debian.tar.xz’ saved [111316/111316]

dpkg-source: info: extracting firebird2.5 in firebird2.5-2.5.5.26952.ds4 dpkg-source: info: unpacking firebird2.5_2.5.5.26952.ds4.orig.tar.xz dpkg-source: info: unpacking firebird2.5_2.5.5.26952.ds4-5.debian.tar.xz dpkg-source: info: applying upstream/core-5068.patch dpkg-source: info: applying out/honour-buildflags.patch dpkg-source: info: applying trim-cflags.patch dpkg-source: info: applying no-rpath.patch dpkg-source: info: applying march-i486.patch dpkg-source: info: applying separate-file-and-sem-perms.patch dpkg-source: info: applying no-spurious-linkage.patch dpkg-source: info: applying parallel-build.patch dpkg-source: info: applying versioned-log-filename.patch dpkg-source: info: applying link_atomic_ops.patch dpkg-source: info: applying out/spelling.patch root@mama:/tmp/firebird2.5# cd firebird2.5-2.5.5.26952.ds4/extern/btyacc/ root@mama:/tmp/firebird2.5/firebird2.5-2.5.5.26952.ds4/extern/btyacc# make CFLAGS=-O2 cc -O2 -c -o closure.o closure.c cc -O2 -c -o error.o error.c cc -O2 -c -o lalr.o lalr.c cc -O2 -c -o lr0.o lr0.c cc -O2 -c -o main.o main.c cc -O2 -c -o mkpar.o mkpar.c cc -O2 -c -o output.o output.c cc -O2 -c -o mstring.o mstring.c cc -O2 -c -o reader.o reader.c cc -O2 -c -o readskel.o readskel.c cc -O2 -c -o skeleton.o skeleton.c cc -O2 -c -o symtab.o symtab.c cc -O2 -c -o verbose.o verbose.c cc -O2 -c -o warshall.o warshall.c cc -o btyacc closure.o error.o lalr.o lr0.o main.o mkpar.o output.o mstring.o reader.o readskel.o skeleton.o symtab.o verbose.o warshall.o main.o: In function create_file_names': main.c:(.text+0x5b8): warning: the use ofmktemp' is dangerous, better use mkstemp' ormkdtemp' root@mama:/tmp/firebird2.5/firebird2.5-2.5.5.26952.ds4/extern/btyacc# ./btyacc ../../src/dsql/parse.y ./btyacc: 11 shift/reduce conflicts, 5 reduce/reduce conflicts. YYTABLESIZE: 70861 root@mama:/tmp/firebird2.5/firebird2.5-2.5.5.26952.ds4/extern/btyacc#

On qemu-m68k:

(sid-m68k-sbuild)root@ikarus:~# cd /tmp (sid-m68k-sbuild)root@ikarus:/tmp# mkdir firebird2.5 (sid-m68k-sbuild)root@ikarus:/tmp# cd firebird2.5/ (sid-m68k-sbuild)root@ikarus:/tmp/firebird2.5# dget -u http://http.debian.net/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4-5.dsc perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = "en_US:en", LC_ALL = (unset), LANG = "en_US.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). dget: retrieving http://http.debian.net/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4-5.dsc --2016-07-05 18:08:31-- http://http.debian.net/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4-5.dsc Resolving http.debian.net (http.debian.net)... 128.31.0.66, 5.153.231.35, 2001:41c8:1000:21::21:35 Connecting to http.debian.net (http.debian.net)|128.31.0.66|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://mirror.liquidtelecom.com/debian/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4-5.dsc [following] --2016-07-05 18:08:32-- http://mirror.liquidtelecom.com/debian/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4-5.dsc Resolving mirror.liquidtelecom.com (mirror.liquidtelecom.com)... 197.155.77.1, 2c0f:fe40:8001:10::1 Connecting to mirror.liquidtelecom.com (mirror.liquidtelecom.com)|197.155.77.1|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 3058 (3.0K) Saving to: 'firebird2.5_2.5.5.26952.ds4-5.dsc'

firebird2.5_2.5.5.26952.ds4-5.dsc 100%[=========================================================================================================================================>] 2.99K --.-KB/s in 0.03s

2016-07-05 18:08:35 (103 KB/s) - 'firebird2.5_2.5.5.26952.ds4-5.dsc' saved [3058/3058]

dget: retrieving http://http.debian.net/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4.orig.tar.xz --2016-07-05 18:08:35-- http://http.debian.net/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4.orig.tar.xz Resolving http.debian.net (http.debian.net)... 128.31.0.66, 5.153.231.35, 2001:41c8:1000:21::21:35 Connecting to http.debian.net (http.debian.net)|128.31.0.66|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://mirror.liquidtelecom.com/debian/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4.orig.tar.xz [following] --2016-07-05 18:08:36-- http://mirror.liquidtelecom.com/debian/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4.orig.tar.xz Resolving mirror.liquidtelecom.com (mirror.liquidtelecom.com)... 197.155.77.1, 2c0f:fe40:8001:10::1 Connecting to mirror.liquidtelecom.com (mirror.liquidtelecom.com)|197.155.77.1|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 4008160 (3.8M) [application/x-tar] Saving to: 'firebird2.5_2.5.5.26952.ds4.orig.tar.xz'

firebird2.5_2.5.5.26952.ds4.orig.tar.xz 100%[=========================================================================================================================================>] 3.82M 1.28MB/s in 3.0s

2016-07-05 18:08:48 (1.28 MB/s) - 'firebird2.5_2.5.5.26952.ds4.orig.tar.xz' saved [4008160/4008160]

dget: retrieving http://http.debian.net/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4-5.debian.tar.xz --2016-07-05 18:08:48-- http://http.debian.net/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4-5.debian.tar.xz Resolving http.debian.net (http.debian.net)... 128.31.0.66, 5.153.231.35, 2001:41c8:1000:21::21:35 Connecting to http.debian.net (http.debian.net)|128.31.0.66|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://mirror.liquidtelecom.com/debian/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4-5.debian.tar.xz [following] --2016-07-05 18:08:49-- http://mirror.liquidtelecom.com/debian/debian/pool/main/f/firebird2.5/firebird2.5_2.5.5.26952.ds4-5.debian.tar.xz Resolving mirror.liquidtelecom.com (mirror.liquidtelecom.com)... 197.155.77.1, 2c0f:fe40:8001:10::1 Connecting to mirror.liquidtelecom.com (mirror.liquidtelecom.com)|197.155.77.1|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 111316 (109K) [application/x-tar] Saving to: 'firebird2.5_2.5.5.26952.ds4-5.debian.tar.xz'

firebird2.5_2.5.5.26952.ds4-5.debian.tar.xz 100%[=========================================================================================================================================>] 108.71K 435KB/s in 0.3s

2016-07-05 18:08:50 (435 KB/s) - 'firebird2.5_2.5.5.26952.ds4-5.debian.tar.xz' saved [111316/111316]

perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = "en_US:en", LC_ALL = (unset), LANG = "en_US.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). dpkg-source: info: extracting firebird2.5 in firebird2.5-2.5.5.26952.ds4 dpkg-source: info: unpacking firebird2.5_2.5.5.26952.ds4.orig.tar.xz dpkg-source: info: unpacking firebird2.5_2.5.5.26952.ds4-5.debian.tar.xz dpkg-source: info: applying upstream/core-5068.patch dpkg-source: info: applying out/honour-buildflags.patch dpkg-source: info: applying trim-cflags.patch dpkg-source: info: applying no-rpath.patch dpkg-source: info: applying march-i486.patch dpkg-source: info: applying separate-file-and-sem-perms.patch dpkg-source: info: applying no-spurious-linkage.patch dpkg-source: info: applying parallel-build.patch dpkg-source: info: applying versioned-log-filename.patch dpkg-source: info: applying link_atomic_ops.patch dpkg-source: info: applying out/spelling.patch (sid-m68k-sbuild)root@ikarus:/tmp/firebird2.5# cd firebird2.5-2.5.5.26952.ds4/extern/btyacc/ (sid-m68k-sbuild)root@ikarus:/tmp/firebird2.5/firebird2.5-2.5.5.26952.ds4/extern/btyacc# make CFLAGS=-O2 cc -O2 -c -o closure.o closure.c cc -O2 -c -o error.o error.c cc -O2 -c -o lalr.o lalr.c cc -O2 -c -o lr0.o lr0.c cc -O2 -c -o main.o main.c cc -O2 -c -o mkpar.o mkpar.c cc -O2 -c -o output.o output.c cc -O2 -c -o mstring.o mstring.c cc -O2 -c -o reader.o reader.c cc -O2 -c -o readskel.o readskel.c cc -O2 -c -o skeleton.o skeleton.c cc -O2 -c -o symtab.o symtab.c cc -O2 -c -o verbose.o verbose.c cc -O2 -c -o warshall.o warshall.c cc -o btyacc closure.o error.o lalr.o lr0.o main.o mkpar.o output.o mstring.o reader.o readskel.o skeleton.o symtab.o verbose.o warshall.o main.o: In function create_file_names': main.c:(.text+0x5b8): warning: the use ofmktemp' is dangerous, better use mkstemp' ormkdtemp' (sid-m68k-sbuild)root@ikarus:/tmp/firebird2.5/firebird2.5-2.5.5.26952.ds4/extern/btyacc# ./btyacc ../../src/dsql/parse.y ./btyacc: 2 rules never reduced ./btyacc: 8 shift/reduce conflicts, 3 reduce/reduce conflicts. YYTABLESIZE: 28188 (sid-m68k-sbuild)root@ikarus:/tmp/firebird2.5/firebird2.5-2.5.5.26952.ds4/extern/btyacc#

vivier commented 7 years ago

Tested with branch "m68k-dev", "gcc (Debian 6.2.1-7) 6.2.1 20161215," and "firebird2.5_2.5.3.26778.ds4-5.dsc"

root@Quad:/tmp/firebird2.5/firebird2.5-2.5.3.26778.ds4/extern/btyacc# ./btyacc ../../src/dsql/parse.y ./btyacc: 11 shift/reduce conflicts, 5 reduce/reduce conflicts. YYTABLESIZE: 70861