Intel® C++ Compiler

Memory leak in ICC 17?

Today I decided to try ICC 2017 Update 1. Halfway into my project the build computer seemed to hang up. I figured out that icpc allocates all RAM (24 GB) even when running with one thread. I restarted the computer and tried again - still the same issue. The code compiles just fine with ICC 2013. I am running on Debian 8. When I killed the process, the following was printed on the command line:

*** Error in `/opt/intel/compilers_and_libraries_2017.1.132/linux/bin/intel64/icpc': double free or corruption (!prev): 0x0000000002001b20 ***

Has anybody else had this issue?

icc 17.0.1 miscompiles valid C code at -O2 and -O3 on x86_64-linux-gnu

Compiler version and platform: 

Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.1.132 Build 20161005 

$ icc -Os small.c; ./a.out; echo $?
1
$ 
$ icc -O2 small.c; ./a.out; echo $?
0
$ icc -O3 small.c; ./a.out; echo $?
0
$ 
$ cat small.c
struct S { char f; };

int a, b, *c = &b;

struct S foo ()
{
  struct S d = { 1 };
  for (; a < 1; a++)
    if (d.f)
      *c = 1;
  return d;
}

int main ()
{
  foo ();
  return b; 
}
$ 

 

icc 17.0.1 miscompiles valid C code at -O1 and above on x86_64-linux-gnu

Compiler version and platform: 

Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.1.132 Build 20161005 

$ icc -O0 small.c; ./a.out; echo $?
1
$ 
$ icc -O1 small.c; ./a.out; echo $?
0
$ 
$ cat small.c
struct
{
  int f:2;
} volatile a = { -1 };

int b = 1;

int main ()
{
  short c = 0;
  if (!(!b || a.f > 0))
    c = 1;
  return c;
}
$ 

 

icc 17.0.1 miscompiles valid C code at -Os and above on x86_64-linux-gnu

Compiler version and platform: 

Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.1.132 Build 20161005 

$ icc -O1 small.c; ./a.out; echo $?
0
$ 
$ icc -Os small.c; ./a.out; echo $?
1
$ 
$ cat small.c
char a[1];

int main ()
{
  unsigned long b = ~0;
  if (!a[0])
    b = 0;
  if (a[0])
    while (1)
      if (a[b])
        break;
  return !a[0] && b;
}
$ 

 

icc 17.0.1 miscompiles valid C code at -O1 and above on x86_64-linux-gnu

Compiler version and platform: 

Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.1.132 Build 20161005 

$ icc -O0 small.c; ./a.out
1
$ 
$ icc -O1 small.c; ./a.out
0
$ 
$ cat small.c
int printf (const char *, ...);

static long a;

int foo (int b)
{
  if (0) 
    if (1)
      return a;
  return b;
}

int main ()
{
  printf ("%d\n", foo (1));
  return 0; 
}
$ 

 

icc 17.0.1 miscompiles valid C code at -O3 on x86_64-linux-gnu

Compiler version and platform: 

Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.1.132 Build 20161005 

$ icc -O2 small.c; ./a.out; echo $?
1
$ 
$ icc -O3 small.c; ./a.out; echo $?
0
$ 
$ cat small.c
short a = 1, b, c; 

void fn1 ()
{
  for (b = 5; b != -1; b -= 7)
    {
      while (c)
        c++;
      if (!b)
        return; 
    }
  a = 0;
}

int main ()
{
  fn1 ();
  return a; 
}
$ 

 

icc 17.0.1 miscompiles valid C code (compiled code SIGFPE) at -O1 and above on x86_64-linux-gnu

Compiler version and platform: 

Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.1.132 Build 20161005 

$ icc -O0 small.c; ./a.out
$ 
$ icc -O1 small.c
$ ./a.out
Floating point exception (core dumped)
$ 
$ cat small.c
volatile struct S
{
  int f:4;
} b;

int a, c = 1, d; 

int main ()
{
  for (; a < 2; a++)
    {
      for (; d < 1; d++)
        b.f = 1;
      b.f = 0 % b.f - 1;
      if (!(c && b.f < 0))
        b.f = 0;
    }
  return 0; 
}
$ 

 

icc 17.0.1 miscompiles valid C code (compiled code SIGFPE) at -Os and above on x86_64-linux-gnu

Compiler version and platform: 

Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.1.132 Build 20161005 

$ icc -O1 small.c; ./a.out
$ 
$ icc -Os small.c
$ ./a.out
Floating point exception (core dumped)
$ 
$ cat small.c
struct
{
  int f0:2;
  int f1:2;
} f = {0, 1};

int a = 3, b, d;
volatile unsigned int c;
char e, g;

int main ()
{
  for (; a; a--)
    {
      char h = ~1 ^ d;
      d = b >> 0 / h;
      int j; 
      if (!(e || f.f0 > c))
        j = b;
      f.f0 = g = b = j;
    }
  return 0; 
}
$ 

 

icc 17.0.1 miscompiles valid C code (compiled code segfaults) at -Os and above on x86_64-linux-gnu

Compiler version and platform: 

Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.1.132 Build 20161005 

$ cat small.c
struct
{
  int f0:24;
  volatile int f1;
} a = {-8, 0}, c[1];

volatile int b, g, i = -8;
int d, h;
unsigned int e;

int main ()
{
  if (!(d < 1 && a.f0 > b))
    g = a.f0;
  a.f0 = a.f0 && h;
  e = g - 5;
  b = i % e; 
  if (b < d)
    c[120].f1;
  if (h)
    while (1)
      ;
  return 0; 
}
$ 

 

Subscribe to Intel® C++ Compiler