Operating System - HP-UX
1832764 Members
3166 Online
110045 Solutions
New Discussion

different numerical results with/without the debugger!

 
Ravi Abrol
Occasional Advisor

different numerical results with/without the debugger!

hi,
i have a big C code running under MPI environment and i am using the totalview debugger, that helps me trace the code on more than one processor. the code runs correctly when i use the debugger and gives a wrong numerical result when i run it without the debugger. not only that, on every run without the debugger i get a different numerical answer.
has someone faced this situation? how do i resolve this problem?
thanks,
ravi
world needs a good debugger!
4 REPLIES 4
Deepak Extross
Honored Contributor

Re: different numerical results with/without the debugger!

Ravi,

Its probably a runtime memory corruption, which the debugger suppresses.
Can you post the code snippet?

Also, make sure that you have '#included' stdlib.h in case you are doing numeric operations.
Ravi Abrol
Occasional Advisor

Re: different numerical results with/without the debugger!

thanks deepak,
it won't be possible to post a code snippet, as i have a main C code 2000+ lines long and about 40 other C codes and about 10 fortran codes that contain functions called by the main C code.
(i have inherited this huge code and am trying to make it work on an HPUX superdome system under the MPI environment. this code is a big number cruncher involving lots and lots of matrix and vector operations.)

as for the stdlib.h issue, i saw that only about 10 of these C files contain #include statements. do you think i should include it in all C files used? i saw one file that contained #include . does that need to be included in all C files too?

thanks,
ravi
world needs a good debugger!
Deepak Extross
Honored Contributor

Re: different numerical results with/without the debugger!

It's just one possibility that a missing #include stdlib is causing this.
For example, if you use atoi() without #including stdlib, no error or warning will be reported at compile-time or runtime, but the result of the atoi will be erroneous and unpredictable.

It could also be a memory corruption caused by inaccurate coding - overshooting memory limits, using initialised memory, etc. Rational's Purify is a great tool for identifying these types of runtime errors.
Ravi Abrol
Occasional Advisor

Re: different numerical results with/without the debugger!

hi deepak,

thanks for your reply! i cannot use purify since it doesn't accept my mpicc compiler. i have included stdlib.h in all C files and it is not helping. the code gives a different numerical value for every run not executed using the debugger.

ravi
world needs a good debugger!