Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
23 Views

segmentation fault with icpc

Hi,

 

Segmentation fault sometimes occurs in a program when icpc is used.

The version of icpc I am using is 17.0.2 20170213, and the version of g++ is 5.2.0.

It does not happen when g++ is used.

This issue was originally found in BOUT++ code. (https://github.com/boutproject/BOUT-dev)

Please have a look at the attached reproducer.

It was written based on BOUT++ code.

If g++ is used:

$ ./a.out
0
0
1
1
1
2
2
2

 

But if icpc is used:

$ ./a.out.intel
0
0
...
Segmentation fault (core dumped)

 

Please note that sometimes the segfault does not occur, but always the output is corrupted.(0 0 0....)

 

The problem does not happen even if icpc is used when

1) a copy constructor is defined (a.out.intel.copy)

2) reference variables are not used (a.out.intel.noref)

 

Though this issue had been fixed in BOUT++ code by doing 2) (https://github.com/boutproject/BOUT-dev/pull/468), but I still suspect this is a bug of intel compiler because the problem does not happen with g++.

Is this a bug of icpc?

 

Best regards,

Daichi

0 Kudos
3 Replies
Highlighted
Employee
23 Views

This looks like a user error. A copy constructor is needed to keep the reference data members valid.

 

DataIterator has several self-references, but no copy constructor to keep them consistent. And of course all the member functions of Test return an object of type DataIterator. At what do those references wind up pointing if the member functions aren’t inlined?

 

0 Kudos
Highlighted
Beginner
23 Views

Judith,

Thank you very much for your answer.

g++ works in that case without user defined copy constructor, so it worked unexpectedly?

 

Best  regards,

Daichi

0 Kudos
Employee
23 Views

 

icc also "works" if you enable optimization (i.e. compiler at -O1 or higher so the code is inlined). That doesn't mean the code is correct.

0 Kudos