C - advice how to catch some weird error

I have some unstable mistake in my program and out-of-idea how to catch it.
I am looking for advice with a way to work it out!

I have in a pretty complicated program (but one source file) set of int-counters - 15, if exactly.
Lately, on final printout I have inpossible value (I am processing 1000 records, but counter shows more than 900 millions number.)

The most strange point is that when I put some printf(..) around the changing the counter statements, another counter becomes unreal, but this one shows correct number.

The same actions (add printf()s) around next one have the same result: that one become correct, but another one changed to huge number.

Finally, if all counters are followed by the printf() statements - all counters are completely reasonable!!
(Acctually, if I removes all debug-printf()s, again, all counters are fine, ... but somewere the problem still exist!!)

Sure, the code compiled without problem and warnings.
I have check the code with 'lint' - everything fine (at least nothing reasonable!)

What would you advice to do to find the problem?
I am not comfortable to leave the code with such condition, but no idea how to catch it!

Please, help!
(no way to post the code here - more than 3K lines, many system(the business system in addition to OS) library, headers..., so, you will not be able to compile it)

I'd trace it with the Data Display Debugger, watching the relevant memory to see what step it changes at.

Corona688
I am at business work station, connecting to the server with SUN SOLARIS, connecting the Oracle and under the company security ...

  • so, I do not have a chance to install it here,
  • same as to copy the source to any my location to install any visual debuger and process it...

Also, I think it would required to recompile with debug option, and that could hide the problem, as it happening when I reviewing all counters changes...

Is there any idea how to catch it without any visual debuger?

You could put trace statements everywhere and gradually narrow down precisely what step the modification happens between perhaps.

You can debug from the commandline, though it's not as easy. That's a first thing to try though -- *does* it still happen with debugging compiled in?

Beyond that my crystal ball's no better than yours.