Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pip installed PyAPSI results in "illegal hardware instruction (core dumped)" for some hardware #13

Open
LGro opened this issue Jun 5, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@LGro
Copy link
Owner

LGro commented Jun 5, 2022

This issue seems to occur when the wheel was built on another system.

Steps to reproduce:

  • Arch Linux
  • CPU: i7 2600
  • Conda env with Python 3.8 or 3.10
  • pip install apsi==0.1.2
  • run example from README

Also reproducible with the following Dockerfile:

FROM python:3.9-slim-bullseye
RUN pip install apsi
COPY ./example.py /example.py
RUN python example.py

Since this seems to happen in the same Docker image that it was built in, I suspect the available CPU instructions as the origin.

@LGro LGro added the bug Something isn't working label Jun 5, 2022
@LGro
Copy link
Owner Author

LGro commented Jun 5, 2022

This issue does not occur with the following CPU

Architecture:            x86_64
  CPU op-mode(s):        32-bit, 64-bit
  Address sizes:         40 bits physical, 48 bits virtual
  Byte Order:            Little Endian
CPU(s):                  1
  On-line CPU(s) list:   0
Vendor ID:               GenuineIntel
  Model name:            Intel Xeon Processor (Skylake, IBRS)
    CPU family:          6
    Model:               85
    Thread(s) per core:  1
    Core(s) per socket:  1
    Socket(s):           1
    Stepping:            4
    BogoMIPS:            4589.21
    Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid tsc_known_freq p
                         ni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti ssbd i
                         brs ibpb fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm avx512f avx512dq rdseed adx smap clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 arat pku ospke md_clear
Virtualization features: 
  Hypervisor vendor:     KVM
  Virtualization type:   full
Caches (sum of all):     
  L1d:                   32 KiB (1 instance)
  L1i:                   32 KiB (1 instance)
  L2:                    4 MiB (1 instance)
  L3:                    16 MiB (1 instance)
NUMA:                    
  NUMA node(s):          1
  NUMA node0 CPU(s):     0
Vulnerabilities:         
  Itlb multihit:         KVM: Mitigation: VMX unsupported
  L1tf:                  Mitigation; PTE Inversion
  Mds:                   Mitigation; Clear CPU buffers; SMT Host state unknown
  Meltdown:              Mitigation; PTI
  Spec store bypass:     Mitigation; Speculative Store Bypass disabled via prctl and seccomp
  Spectre v1:            Mitigation; usercopy/swapgs barriers and __user pointer sanitization
  Spectre v2:            Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP disabled, RSB filling
  Srbds:                 Not affected
  Tsx async abort:       Mitigation; Clear CPU buffers; SMT Host state unknown
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 85
model name	: Intel Xeon Processor (Skylake, IBRS)
stepping	: 4
microcode	: 0x1
cpu MHz		: 2294.608
cache size	: 16384 KB
physical id	: 0
siblings	: 1
core id		: 0
cpu cores	: 1
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 syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti ssbd ibrs ibpb fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm avx512f avx512dq rdseed adx smap clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 arat pku ospke md_clear
bugs		: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit
bogomips	: 4589.21
clflush size	: 64
cache_alignment	: 64
address sizes	: 40 bits physical, 48 bits virtual

@LGro LGro changed the title pip installed PyAPSI results in "illegal hardware instruction (core dumped)" pip installed PyAPSI results in "illegal hardware instruction (core dumped)" for some hardware Jun 5, 2022
LGro added a commit that referenced this issue Jun 5, 2022
LGro added a commit that referenced this issue Jun 5, 2022
@LGro
Copy link
Owner Author

LGro commented Jun 5, 2022

The CPU that works has the following flags over the one where it doesn't:

'pdpe1gb', 'movbe', 'avx512bw', 'rdseed', 'fma', 'ospke', 'smap', 'bmi2', 'xgetbv1', 'f16c', '3dnowprefetch', 'avx512cd', 'smep', 'avx512dq', 'hle', 'abm', 'avx512f', 'xsavec', 'avx2', 'fsgsbase', 'erms', 'clwb', 'invpcid', 'brs', 'hypervisor', 'avx512vl', 'bmi1', 'i', 'rtm', 'rdrand', 'adx', 'pku', 'tsc_known_freq', 'invpcid_single', 'cpuid_fault'

While the CPU that doesn't work has the following flags over the one where it does:

'stibp', 'tm2', 'smx', 'dtherm', 'vpid', 'pts', 'flexpriority', 'epb', 'pdcm', 'ibrs', 'dts', 'bts', 'ida', 'dtes64', 'ept', 'acpi', 'tm', 'pln', 'est', 'pebs', 'xtpr', 'ht', 'tpr_shadow', 'vmx', 'arch_perfmon', 'aperfmperf', 'vnmi', 'flush_l1d', 'ds_cpl', 'monitor', 'pbe', 'nonstop_tsc'

@heurainbow
Copy link

Hi, I build a docker image given base.Dockerfile. I found this dockerfile not installing APSI. So, I use vcpkg install APSI ./vcpkg install apsi. Then, I pip install apsi in the container, and "illegal hardware instruction (core dumped)" came out. Any solution?

@heurainbow
Copy link

heurainbow commented Jun 24, 2022

Hi, I build a docker image given base.Dockerfile. I found this dockerfile not installing APSI. So, I use vcpkg install APSI ./vcpkg install apsi. Then, I pip install apsi in the container, and "illegal hardware instruction (core dumped)" came out. Any solution?

my bad, pyapsi would build apsi in external by poetry run python setup.py bdist_wheel. It's working now by building apsi as in py.Dockerfile.

@LGro
Copy link
Owner Author

LGro commented Jun 25, 2022

Hi @heurainbow, good to hear that you found your way to py.Dockerfile. Due to the need to patch out AVX2 support (see #11 and microsoft/APSI#25) the current build setup is a bit more complex than I'd like. My preference would indeed be to use vcpkg to install apsi like you intuitively tried.
Just out of curiosity, since I don't have many datapoints on that yet, did you try pip installing pyapsi from pypi.org and if so, did you face the illegal instructions error outlined in this issue or did something else happen?

@heurainbow
Copy link

I would face the same error if I only pip install apsi in the base container.

@LGro
Copy link
Owner Author

LGro commented Jul 10, 2022

Would you be open to posting the output of lscpu (especially the flags section) from the affected system here, to help narrow down which cpu specific features cause the above mentioned incompatibility, @heurainbow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants