Package: g++-mingw-w64-x86-64
Version: 8.3.0-19+21.4
Severity: normal
File: /usr/bin/x86_64-w64-mingw32-g++-win32
Dear Maintainer,
I wrote this C++ source code and saved it in `bug.cpp`:
#include <cstdint>
#include <cstdio>
#include <cstdlib>
typedef int64_t int2 __attribute__ ((vector_size (16)));
typedef int64_t int4 __attribute__ ((vector_size (32)));
typedef int64_t int8 __attribute__ ((vector_size (64)));
typedef int64_t int16 __attribute__ ((vector_size (128)));
__attribute__ ((noinline))
bool any(const int64_t &i) {
return i;
}
__attribute__ ((noinline))
bool any(const int2 &i) {
return (((i[0] || i[1])));
}
__attribute__ ((noinline))
bool any(const int4 &i) {
return (((i[0] || i[1]) || (i[2] || i[3])));
}
__attribute__ ((noinline))
bool any(const int8 &i) {
return (((i[0] || i[1]) || (i[2] || i[3])) ||
((i[4] || i[5]) || (i[6] || i[7])));
}
__attribute__ ((noinline))
bool any(const int16 &i) {
return (((i[0] || i[1]) || (i[2] || i[3])) ||
((i[4] || i[5]) || (i[6] || i[7]))) ||
(((i[8] || i[9]) || (i[10] || i[11])) ||
((i[12] || i[13]) || (i[14] || i[15])));
}
typedef double double2 __attribute__ ((vector_size (16)));
typedef double double4 __attribute__ ((vector_size (32)));
typedef double double8 __attribute__ ((vector_size (64)));
typedef double double16 __attribute__ ((vector_size (128)));
template <typename R, typename T>
__attribute__ ((noinline))
R broadcast(T x) { return R(x); }
template <>
__attribute__ ((noinline))
double2 broadcast<double2 ,double>(double x) { double2 r = { x, x
}; return r; }
template <>
__attribute__ ((noinline))
double4 broadcast<double4 ,double>(double x) { double4 r = { x, x,
x, x }; return r; }
template <>
__attribute__ ((noinline))
double8 broadcast<double8 ,double>(double x) { double8 r = { x, x,
x, x, x, x, x, x }; return r; }
template <>
__attribute__ ((noinline))
double16 broadcast<double16,double>(double x) { double16 r = { x,
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x }; return r; }
int main(int argc, char **argv)
{
if (argc > 1)
{
int N = atoi(argv[1]);
switch (N)
{
case 1: { double x = broadcast<double ,double>(1.0);
return any(x != 1.0); }
case 2: { double2 x = broadcast<double2 ,double>(1.0);
return any(x != 1.0); }
case 4: { double4 x = broadcast<double4 ,double>(1.0);
return any(x != 1.0); }
case 8: { double8 x = broadcast<double8 ,double>(1.0);
return any(x != 1.0); }
case 16: { double16 x = broadcast<double16,double>(1.0);
return any(x != 1.0); }
}
}
return 1;
}
I compiled it like this:
$ x86_64-w64-mingw32-g++ bug.cpp -march=native -O3
bug.cpp: In function ‘R broadcast(T) [with R = __vector(8) double;
T = double]’:
bug.cpp:56:45: warning: AVX512F vector return without AVX512F
enabled changes the ABI [-Wpsabi]
double8 broadcast<double8 ,double>(double x) { double8 r = { x,
x, x, x, x, x, x, x }; return r; }
^
I ran it on the same host like this, and it crashed:
$ ./a.exe 4
wine: Unhandled page fault on read access to 0xffffffffffffffff at
address 0x4016a8 (thread 002a), starting debugger...
002c:fixme:dbghelp:elf_search_auxv can't find symbol in module
002c:fixme:dbghelp:elf_search_auxv can't find symbol in module
002c:fixme:dbghelp:elf_search_auxv can't find symbol in module
002c:fixme:dbghelp:elf_search_auxv can't find symbol in module
002c:fixme:dbghelp:elf_search_auxv can't find symbol in module
Unhandled exception: page fault on read access to
0xffffffffffffffff in 64-bit code (0x00000000004016a8).
002c:fixme:dbghelp:elf_search_auxv can't find symbol in module
002c:fixme:dbghelp:interpret_function_table_entry PUSH_MACHFRAME 6
Register dump:
rip:00000000004016a8 rsp:000000000032f928 rbp:00000000004619e0
eflags:00010203 ( R- -- I - - -C)
rax:000000000032fa10 rbx:000000000032fa80 rcx:000000000032fa10
rdx:0000000000405000
rsi:0000000000000002 rdi:00000000004619e0 r8:00000000ffffffd0
r9:0000000000000000 r10:0000000000000002
r11:0000000000461a68 r12:0000000000000018 r13:0000000000000010
r14:0000000000000000 r15:0000000000000000
Stack dump:
0x000000000032f928: 00000000004031e8 0000000000000000
0x000000000032f938: 0000000000000000 0000000000000000
0x000000000032f948: 0000000000000000 0000000000202020
0x000000000032f958: 0000000020000000 0000000000ffffff
0x000000000032f968: ffffffff00ffffff 0000000000202020
0x000000000032f978: 0000000000000000 0000000000000000
0x000000000032f988: 0000000000000000 0000000000000000
0x000000000032f998: 0000000000000000 0000000000000000
0x000000000032f9a8: 0000000000000000 0000000000000000
0x000000000032f9b8: 0000000000000000 0000000000000000
0x000000000032f9c8: 0000000000000000 0000000000000000
0x000000000032f9d8: 0000000000000000 0000000000000000
Backtrace:
=>0 0x00000000004016a8 in a (+0x16a8) (0x00000000004619e0)
1 0x00000000004031e8 in a (+0x31e7) (0x00000000004619e0)
0x00000000004016a8: ldsl %ebp,%edi
Modules:
Module Address Debug info Name (20 modules)
PE 400000- 458000 Dwarf a
ELF 7b400000- 7b831000 Deferred kernel32<elf>
\-PE 7b420000- 7b831000 \ kernel32
ELF 7bc00000- 7bd2c000 Deferred ntdll<elf>
\-PE 7bc20000- 7bd2c000 \ ntdll
ELF 7c000000- 7c005000 Deferred <wine-loader>
ELF 7f8e5120b000- 7f8e51239000 Deferred libtinfo.so.6
ELF 7f8e51239000- 7f8e51262000 Deferred libncurses.so.6
ELF 7f8e51362000- 7f8e51445000 Deferred msvcrt<elf>
\-PE 7f8e51380000- 7f8e51445000 \ msvcrt
ELF 7f8e51445000- 7f8e5145a000 Deferred libnss_files.so.2
ELF 7f8e5145a000- 7f8e51473000 Deferred libnsl.so.1
ELF 7f8e51473000- 7f8e51480000 Deferred libnss_nis.so.2
ELF 7f8e51480000- 7f8e5148b000 Deferred libnss_compat.so.2
ELF 7f8e51970000- 7f8e5198a000 Deferred libgcc_s.so.1
ELF 7f8e5198a000- 7f8e51b0d000 Deferred libm.so.6
ELF 7f8e51b0f000- 7f8e51b14000 Deferred libdl.so.2
ELF 7f8e51b14000- 7f8e51cd5000 Deferred libc.so.6
ELF 7f8e51cd5000- 7f8e51cf6000 Deferred libpthread.so.0
ELF 7f8e51edf000- 7f8e51f09000 Deferred
ld-linux-x86-64.so.2
Threads:
process tid prio (all id:s are in hex)
0000000e services.exe
00000020 0
0000001b 0
00000015 0
00000014 0
00000013 0
00000010 0
0000000f 0
00000011 winedevice.exe
00000018 0
00000017 0
00000016 0
00000012 0
00000019 plugplay.exe
0000001d 0
0000001c 0
0000001a 0
0000001e winedevice.exe
00000025 0
00000022 0
00000021 0
0000001f 0
00000023 explorer.exe
00000028 0
00000027 0
00000026 0
00000024 0
00000029 (D) Z:\home\claude\a.exe
0000002a 0 <==
System information:
Wine build: wine-4.0 (Debian 4.0-2)
Platform: x86_64
Version: Windows 7
Host system: Linux
Host version: 4.19.0-5-amd64
Running it with other arguments does not crash.
I expect a program compiled with -march=native to work on the machine
on which it was compiled.
This seems to be a mingw issue (or possibly a wine issue, also occurs with
wine-development), as compiling with regular x86-64 g++ does not exhibit
the problem.
$ g++ --version
g++ (Debian 8.3.0-6) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There
is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
$ apt-cache policy g++
g++:
Installed: 4:8.3.0-1
Candidate: 4:8.3.0-1
Version table:
4:9.2.1-3 500
500 http://ftp.uk.debian.org/debian unstable/main amd64
Packages
*** 4:8.3.0-1 990
990 http://ftp.uk.debian.org/debian buster/main amd64 Packages
100 /var/lib/dpkg/status
$ apt-cache policy wine
wine:
Installed: 4.0-2
Candidate: 4.0-2
Version table:
4.0.2-1 500
500 http://ftp.uk.debian.org/debian unstable/main amd64
Packages
500 http://ftp.uk.debian.org/debian unstable/main i386 Packages
*** 4.0-2 990
990 http://ftp.uk.debian.org/debian buster/main amd64 Packages
990 http://ftp.uk.debian.org/debian buster/main i386 Packages
100 /var/lib/dpkg/status
$ apt-cache policy wine-development
wine-development:
Installed: 4.7-1
Candidate: 4.7-1
Version table:
*** 4.7-1 500
500 http://ftp.uk.debian.org/debian unstable/main amd64
Packages
500 http://ftp.uk.debian.org/debian unstable/main i386 Packages
100 /var/lib/dpkg/status
4.2-4 990
990 http://ftp.uk.debian.org/debian buster/main amd64 Packages
990 http://ftp.uk.debian.org/debian buster/main i386 Packages
Here's my CPU:
$ cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 23
model : 8
model name : AMD Ryzen 7 2700X Eight-Core Processor
stepping : 2
microcode : 0x800820b
cpu MHz : 1985.533
cache size : 512 KB
physical id : 0
siblings : 16
core id : 0
cpu cores : 8
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext
fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid
extd_apicid aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1
sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm
extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw skinit wdt
tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb
hw_pstate sme ssbd sev ibpb vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed
adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 xsaves clzero irperf
xsaveerptr arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean
flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload
vgif overflow_recov succor smca
bugs : sysret_ss_attrs null_seg spectre_v1 spectre_v2
spec_store_bypass
bogomips : 7399.05
TLB size : 2560 4K pages
clflush size : 64
cache_alignment : 64
address sizes : 43 bits physical, 48 bits virtual
power management: ts ttp tm hwpstate cpb eff_freq_ro [13] [14]
[snip 15 more instances]
Thanks,
Claude
-- System Information:
Debian Release: 10.0
APT prefers stable
APT policy: (990, 'stable'), (500, 'stable-debug'), (500,
'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 4.19.0-5-amd64 (SMP w/16 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8),
LANGUAGE=en_GB:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages g++-mingw-w64-x86-64 depends on:
ii gcc-mingw-w64-base 8.3.0-19+21.4
ii gcc-mingw-w64-x86-64 8.3.0-19+21.4
ii libc6 2.28-10
ii libgcc1 1:8.3.0-6
ii libgmp10 2:6.1.2+dfsg-4
ii libisl19 0.20-2
ii libmpc3 1.1.0-1
ii libmpfr6 4.0.2-1
ii libstdc++6 8.3.0-6
ii zlib1g 1:1.2.11.dfsg-1
g++-mingw-w64-x86-64 recommends no packages.
Versions of packages g++-mingw-w64-x86-64 suggests:
pn gcc-8-locales <none>
-- no debconf information