- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I saw one bit flip in the address incrementation. Here is a simple example to demonstrate that
test.c
------------------------------------------------------------------
#include
#include
typedef struct mystruct_s{
char data[1920];
}site;
int main(int argc, char** argv)
{
int i;
int sites_on_node = 28*28*28*96;
unsigned long size = sites_on_node*sizeof(site);
site* lattice = (site*)malloc(size);
if (lattice == NULL){
printf("ERROR: malloc failed for lattice\\n");
exit(1);
}
site* s;
int j;
for(i=0, s=lattice; i < sites_on_node; i++, s++){
if (s < lattice || s > (lattice + sites_on_node)){
printf("ERROR: wrong address\\n");
exit(1);
}
if (i > 1118479&& i <= 1118485){
printf("i=%d, s=%p\\n", i, s); fflush(stdout);
}
for(j=0; j < 3; j++){
if (i > 1118479 && i <= 1118485){
printf("inside dir loop: i=%d, s=%p\\n", i, s); fflush(stdout);
}
s->data = 1;
}
}
printf("data=%d\\n", lattice[1024].data[0]);
printf("loop done\\n"); fflush(stdout);
return 0;
}
--------------------------------------------------------------------------------------------------
Compiling the code with icc 11.1, optimization level -O3 will make the program segfault. Compiling
with -O0 works. gcc works with -O0/-O3
$ icc --version
icc (ICC) 11.1 20090511
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
$ icc -O3 -o test test.c
$ ./test
i=1118480, s=0x7fb11bfd6810
inside dir loop: i=1118480, s=0x7fb11bfd6810
inside dir loop: i=1118480, s=0x7fb11bfd6810
inside dir loop: i=1118480, s=0x7fb11bfd6810
i=1118481, s=0x7fb11bfd6f90
inside dir loop: i=1118481, s=0x7fb11bfd6f90
inside dir loop: i=1118481, s=0x7fb11bfd6f90
inside dir loop: i=1118481, s=0x7fb11bfd6f90
i=1118482, s=0x7fb11bfd7710
inside dir loop: i=1118482, s=0x7fb01bfd7710
Segmentation fault
$ icc -O0 -o test test.c
$ ./test
i=1118480, s=0x7f60f6d0f810
inside dir loop: i=1118480, s=0x7f60f6d0f810
inside dir loop: i=1118480, s=0x7f60f6d0f810
inside dir loop: i=1118480, s=0x7f60f6d0f810
i=1118481, s=0x7f60f6d0ff90
inside dir loop: i=1118481, s=0x7f60f6d0ff90
inside dir loop: i=1118481, s=0x7f60f6d0ff90
inside dir loop: i=1118481, s=0x7f60f6d0ff90
i=1118482, s=0x7f60f6d10710
inside dir loop: i=1118482, s=0x7f60f6d10710
inside dir loop: i=1118482, s=0x7f60f6d10710
inside dir loop: i=1118482, s=0x7f60f6d10710
i=1118483, s=0x7f60f6d10e90
inside dir loop: i=1118483, s=0x7f60f6d10e90
inside dir loop: i=1118483, s=0x7f60f6d10e90
inside dir loop: i=1118483, s=0x7f60f6d10e90
i=1118484, s=0x7f60f6d11610
inside dir loop: i=1118484, s=0x7f60f6d11610
inside dir loop: i=1118484, s=0x7f60f6d11610
inside dir loop: i=1118484, s=0x7f60f6d11610
i=1118485, s=0x7f60f6d11d90
inside dir loop: i=1118485, s=0x7f60f6d11d90
inside dir loop: i=1118485, s=0x7f60f6d11d90
inside dir loop: i=1118485, s=0x7f60f6d11d90
data=1
loop done
Before it segfaults, there is a bit flop for the address "s"
s=0x7fb11bfd7710 ---> s=0x7fb01bfd7710
Please let me know if you can reproduce this problem
thanks
-Guochun
I saw one bit flip in the address incrementation. Here is a simple example to demonstrate that
test.c
------------------------------------------------------------------
#include
#include
typedef struct mystruct_s{
char data[1920];
}site;
int main(int argc, char** argv)
{
int i;
int sites_on_node = 28*28*28*96;
unsigned long size = sites_on_node*sizeof(site);
site* lattice = (site*)malloc(size);
if (lattice == NULL){
printf("ERROR: malloc failed for lattice\\n");
exit(1);
}
site* s;
int j;
for(i=0, s=lattice; i < sites_on_node; i++, s++){
if (s < lattice || s > (lattice + sites_on_node)){
printf("ERROR: wrong address\\n");
exit(1);
}
if (i > 1118479&& i <= 1118485){
printf("i=%d, s=%p\\n", i, s); fflush(stdout);
}
for(j=0; j < 3; j++){
if (i > 1118479 && i <= 1118485){
printf("inside dir loop: i=%d, s=%p\\n", i, s); fflush(stdout);
}
s->data
}
}
printf("data=%d\\n", lattice[1024].data[0]);
printf("loop done\\n"); fflush(stdout);
return 0;
}
--------------------------------------------------------------------------------------------------
Compiling the code with icc 11.1, optimization level -O3 will make the program segfault. Compiling
with -O0 works. gcc works with -O0/-O3
$ icc --version
icc (ICC) 11.1 20090511
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
$ icc -O3 -o test test.c
$ ./test
i=1118480, s=0x7fb11bfd6810
inside dir loop: i=1118480, s=0x7fb11bfd6810
inside dir loop: i=1118480, s=0x7fb11bfd6810
inside dir loop: i=1118480, s=0x7fb11bfd6810
i=1118481, s=0x7fb11bfd6f90
inside dir loop: i=1118481, s=0x7fb11bfd6f90
inside dir loop: i=1118481, s=0x7fb11bfd6f90
inside dir loop: i=1118481, s=0x7fb11bfd6f90
i=1118482, s=0x7fb11bfd7710
inside dir loop: i=1118482, s=0x7fb01bfd7710
Segmentation fault
$ icc -O0 -o test test.c
$ ./test
i=1118480, s=0x7f60f6d0f810
inside dir loop: i=1118480, s=0x7f60f6d0f810
inside dir loop: i=1118480, s=0x7f60f6d0f810
inside dir loop: i=1118480, s=0x7f60f6d0f810
i=1118481, s=0x7f60f6d0ff90
inside dir loop: i=1118481, s=0x7f60f6d0ff90
inside dir loop: i=1118481, s=0x7f60f6d0ff90
inside dir loop: i=1118481, s=0x7f60f6d0ff90
i=1118482, s=0x7f60f6d10710
inside dir loop: i=1118482, s=0x7f60f6d10710
inside dir loop: i=1118482, s=0x7f60f6d10710
inside dir loop: i=1118482, s=0x7f60f6d10710
i=1118483, s=0x7f60f6d10e90
inside dir loop: i=1118483, s=0x7f60f6d10e90
inside dir loop: i=1118483, s=0x7f60f6d10e90
inside dir loop: i=1118483, s=0x7f60f6d10e90
i=1118484, s=0x7f60f6d11610
inside dir loop: i=1118484, s=0x7f60f6d11610
inside dir loop: i=1118484, s=0x7f60f6d11610
inside dir loop: i=1118484, s=0x7f60f6d11610
i=1118485, s=0x7f60f6d11d90
inside dir loop: i=1118485, s=0x7f60f6d11d90
inside dir loop: i=1118485, s=0x7f60f6d11d90
inside dir loop: i=1118485, s=0x7f60f6d11d90
data=1
loop done
Before it segfaults, there is a bit flop for the address "s"
s=0x7fb11bfd7710 ---> s=0x7fb01bfd7710
Please let me know if you can reproduce this problem
thanks
-Guochun
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can reproduce it. It looks like the compiler bug. I will report it to engineering team for fix.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, looks like this got resolved in 11.1 update 7. Let us know if you have any further problems.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page