PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Detecting uninitialized variables
Goto page 1, 2  Next
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Debugging and Profiling
View previous topic :: View next topic  
Author Message
tsalem



Joined: 25 Mar 2010
Posts: 22

PostPosted: Tue Mar 30, 2010 1:51 pm    Post subject: Detecting uninitialized variables Reply with quote

Is there any way, through a compiler option or within the debugger, to initialize program variables in order to detect usage of uninitialized variables.

Some compilers have an option to set all variables to NaN or some such value. That way, when variables are used without having been initialized, the program terminates.
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 5815
Location: The Portland Group Inc.

PostPosted: Tue Mar 30, 2010 3:26 pm    Post subject: Reply with quote

Hi tsalem,

The flag "-Msave", which applies the SAVE attribute to all local variables, has a side effect of initializing variables to zero. Though, the best method I've found to detect UMRs is to use Valgrind (www.valgrind.org).

- Mat
Back to top
View user's profile
Malcolm Bibby



Joined: 16 Nov 2009
Posts: 33

PostPosted: Wed Mar 31, 2010 7:25 am    Post subject: Reply with quote

Good morning Mat.

I picked up on your favorable comment about Valgrind and have downloaded it. Do you have any suppression files that you have added for when you use it? If so, would you mind sharing them with me?

Thanks

Malcolm Bibby
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 5815
Location: The Portland Group Inc.

PostPosted: Wed Mar 31, 2010 8:29 am    Post subject: Reply with quote

Hi Malcolm,

Suppression files are application dependent so I don't use them.

Sorry,
Mat
Back to top
View user's profile
Malcolm Bibby



Joined: 16 Nov 2009
Posts: 33

PostPosted: Wed Mar 31, 2010 8:44 am    Post subject: Reply with quote

Mat, I used valgrind on my code that breaks with -gopt -O2.

Using memcheck, I get 7 contexts where valgrind reports an error. The message is:

Conditional jump or move depends on uninitialised value(s)
at 0x71C53ED: pgf90_trim (in /opt/pgi/linux86-64/10.3/libso/libpgf90.so)

In each case, I have printed out the argument to trim to be sure it is there and what I expect. It is.


The other 2 contexts look like they might lead me to the problem in my code.

Would you please respond to the error message above.

Thanks

Malcolm
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Debugging and Profiling All times are GMT - 7 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group