Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

Variable died for no reason

GVasi4
Beginner
360 Views

During the C++ application execution one of the variables dies for no reason. I think that the causes of this problem are connected to memory. However, I don't have any ideas how to solve this problem. What could be the cause of this problem?

0 Kudos
6 Replies
GVasi4
Beginner
360 Views

It seems that site doesn't work correctly so I have to continue here:

Hi!

I discovered that some simple arithmetic OpenMP parallel programs runs faster with using icpc compiler instead of g++.
However, when I have tried to compile big OpenMP application (which works correctly with g++) with icpc, it has broken. Using manual code debugging I have discovered that the issue is that one of the variables dies for no reason. I have faced this issue earlier with this application and g++ compiler, but in different mode. It works like:
//no parallel code before this problem
cout<<"var is alive"<<endl;//all works correctly
cout<<var<<endl;
var2 = 0;
cout<<"var is dead"<<endl;
cout<<var<<endl;//program dies

I face this problem on a completely different devices, so I think that it doesn't matter. Are there any general causes of such phenomena? What should I do to solve this problem?

Vladimir_P_Intel2
360 Views

Grigorii Vasilev wrote:

I have faced this issue earlier with this application and g++ compiler, but in different mode. It works like:

...

You have the answer in this sentence - something is wrong in your code. it looks one thread has overwritten a stack of another thread

1. is "program dies" segfault, kill, illegal instruction or what? what is the back trace?

2. is the problem appears in serial block or in parallel section?

GVasi4
Beginner
360 Views

Problem is solved. In my particular case the cause of the problem was that absolutely another variable was changed by different threads/functions, so I have made that variable const.

So, if you have similar problem you should check all code.

RahulV_intel
Moderator
360 Views

Hi,

Since your problem is solved, can we close this thread?

GVasi4
Beginner
360 Views

Hi!

Yes.

RahulV_intel
Moderator
360 Views

Thanks for the confirmation.

Reply