Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

icc crash

Karthik_G_Intel1
Employee
577 Views

Hello,

I get a crash when trying to compile a C/C++ program with icc

icc -O3 fail.cc
": internal error: ** segmentation violation signal raised **
Access violation or stack overflow. Please contact Support.

compilation aborted for fail.cc (code 4)

Version:

icc (ICC) 14.0.2 20140120
Copyright (C) 1985-2014 Intel Corporation.  All rights reserved.


System: CentOS 6.5 Linux, 64 bit (kernel version: 2.6.32-431.5.1.el6.x86_64)

Attached the fail.cc file. The problem only occurs when both _may_i_use_cpu_feature and __cpuid are used together.

#include <stdlib.h>
#include <stdio.h>
#include <immintrin.h>

bool is_cpuid_ecx_bit_set(int eax, int bitidx)
{
  //int ecx = 0, edx = 0, ebx = 0;
  //__asm__ ("cpuid"
      //:"=b" (ebx),
      //"=c" (ecx),
      //"=d" (edx)
      //:"a" (eax)
      //);  
  //return (((ecx >> bitidx)&1) == 1);
  int cpuinfo[4];
  int infotype = eax;
  __cpuid(cpuinfo, infotype);
  return (((cpuinfo[2] >> bitidx) & 1) == 1);
}

main()
{
  int eax = 1;
  if(_may_i_use_cpu_feature(_FEATURE_AVX) > 0)
    //if(false)
    printf("true\n");
  else
    if(is_cpuid_ecx_bit_set(eax, 28))
      printf("core true\n");
    else
      printf("core false\n");
  return 0;
}

 

 

 

0 Kudos
1 Solution
Judith_W_Intel
Employee
577 Views

 

Thank you for reporting this bug, I have entered it in our internal bug tracking database (number

DPD200254737).

The crash is occurring in some compiler code that deals with restructuring of blocks so I think a workaround is to change the code so that the call to _may_i_use_cpu_feature is not inside a block, i.e.:

 

Change this:

  if(_may_i_use_cpu_feature(_FEATURE_AVX) > 0) {
 

to:

  bool b = _may_i_use_cpu_feature(_FEATURE_AVX);
  if (b > 0) {
 

Sorry for the inconvenience.

Judy

 

 

View solution in original post

0 Kudos
2 Replies
Judith_W_Intel
Employee
578 Views

 

Thank you for reporting this bug, I have entered it in our internal bug tracking database (number

DPD200254737).

The crash is occurring in some compiler code that deals with restructuring of blocks so I think a workaround is to change the code so that the call to _may_i_use_cpu_feature is not inside a block, i.e.:

 

Change this:

  if(_may_i_use_cpu_feature(_FEATURE_AVX) > 0) {
 

to:

  bool b = _may_i_use_cpu_feature(_FEATURE_AVX);
  if (b > 0) {
 

Sorry for the inconvenience.

Judy

 

 

0 Kudos
Karthik_G_Intel1
Employee
577 Views

Thanks - that worked.

0 Kudos
Reply