fast_memcpy segfaults on linux x86_64
Brought to you by:
konst
make fails at:
(beyehlp/beyehlp lzss/lzss beyehlp.prj)
Using beyehlp.prj as project
Processing: ../doc/licence.txt
Original : 16488 bytes
Packed : 7696 bytes
Compress ratio : 46.6%
Elapsed time : 0 msec
Segmentation fault
make[1]: *** [help] Error 139
Attached my GDB session log. Here's the "illegal instruction":
=> 0x0000000000409fc8 <+520>: vmovdqa (%r9),%xmm0
GDB session log
That happens because you are using gcc-.4.4+ which generates AVX opcodes for non AVX architectures:
=> 0x0000000000409fc8 <+520>: vmovdqa (%r9),%xmm0
0x0000000000409fcd <+525>: vmovdqa 0x10(%r9),%xmm1
0x0000000000409fd3 <+531>: vmovdqa 0x20(%r9),%xmm2
0x0000000000409fd9 <+537>: vmovdqa 0x30(%r9),%xmm3
0x0000000000409fdf <+543>: vmovdqa 0x40(%r9),%xmm4
0x0000000000409fe5 <+549>: vmovdqa 0x50(%r9),%xmm5
0x0000000000409feb <+555>: vmovdqa 0x60(%r9),%xmm6
0x0000000000409ff1 <+561>: vmovdqa 0x70(%r9),%xmm7
I would recommend you to use -march=native optimization with your compiler
I've tried to configure with CFLAGS="-march=native" and nothing changes.
Configure says:
Checking for CFLAGS ... -march=native -mtune=generic -O3 -pipe -fno-fast-math -mfancy-math-387 -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -fno-tree-vect-loop-version -fno-vect-cost-model -mmmx -m3dnow -msse -msse2 -msse3 -mssse3 -msse4 -mpclmul -maes -mavx -fopenmp -Werror-implicit-function-declaration -Wextra
try -mtune=native too
Thanks for your suggestions, but no change. GCC is still emitting vmovdqa instructions. This is a Core 2 Duo:
$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 15
model name : Intel(R) Core(TM)2 Duo CPU E4600 @ 2.40GHz
stepping : 13
cpu MHz : 1200.000
cache size : 2048 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 10
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm lahf_lm
bogomips : 4787.84
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:
processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 15
model name : Intel(R) Core(TM)2 Duo CPU E4600 @ 2.40GHz
stepping : 13
cpu MHz : 1200.000
cache size : 2048 KB
physical id : 0
siblings : 2
core id : 1
cpu cores : 2
apicid : 1
initial apicid : 1
fpu : yes
fpu_exception : yes
cpuid level : 10
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm lahf_lm
bogomips : 4788.03
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:
Try:
CFLAGS="-O2" ./configure --prefix=/your_location
That won't work for me, because configure always overrides the -O option with -O3. Even when using the --cflags argument.
Checking for CFLAGS ... -O2 -march=k8 -m64 -mtune=generic -O3 -pipe -fno-fast-math -mfancy-math-387 -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -fno-tree-vect-loop-version -fno-vect-cost-model -mmmx -m3dnow -msse -msse2 -msse3 -mssse3 -msse4 -mpclmul -maes -mavx -fopenmp -Werror-implicit-function-declaration -Wextra
Notice the -O3 as the 5th option; my -O2 is the 1st. With this configuration, beyehlp still segfaults. Modifying the configure script to append -O2 to the end doesn't do the trick, and -O0 doesn't fix it either.
So far, --disable-fastmemcpy at configure-time is the only known way to build beye in my environment. This might affect other amd64 users?
try SVN changeset [12]
Hi nickols_k, I still get a segfault on SVN r14 without --disable-fastmemcpy.