C - advice how to catch some weird error


 
Thread Tools Search this Thread
Top Forums Programming C - advice how to catch some weird error
# 1  
Old 04-15-2010
Network 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)
# 2  
Old 04-15-2010
I'd trace it with the Data Display Debugger, watching the relevant memory to see what step it changes at.
# 3  
Old 04-15-2010
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?
# 4  
Old 04-15-2010
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk weird error

Here is the awk code i wrote : if ; then gawk -v field_position="$field_position" -v field_length="$field_length" -v header="$header" -v trailer="$trailer" -v lr="$lr" '{ if(NR==1&&header=="1") { next } if(NR==lr&&trailer=="1") { next }... (1 Reply)
Discussion started by: ysvsr1
1 Replies

2. Shell Programming and Scripting

How to catch sql error in script?

Hi Gurus, I have a script which send sql query to oracle db and return value to my script. dummy code like below: sqlplus -s user/${PASSWD}@${ORACLE_SID} @${DIR}/query.sql > outputfile using above code, when query has error, it send error to same out put file and exit code is 0, is... (6 Replies)
Discussion started by: ken6503
6 Replies

3. Shell Programming and Scripting

Weird Perl error using db2.

I have having a heck of a time figuring this out so any help is much appreciated. Here is the code where it seems to be dying, I bolded the part it is complaining about: $sth = $dbh->prepare( $query ) or die "error with query\n"; $sth->execute() or die "error executing query ...\n"; while(... (1 Reply)
Discussion started by: savigabi
1 Replies

4. Shell Programming and Scripting

Unable to catch the redirection error when the disk is full

Hi Experts, Problem summary : I am facing the below problem on huge files when the disk is getting full on the half way through the execution. If the disk was already full , the commands fail & everything is fine. Sample Code : head_rec_data_file=`head -1 sample_file.txt` cat... (9 Replies)
Discussion started by: Pruthviraj_shiv
9 Replies

5. UNIX for Dummies Questions & Answers

Weird Error moving a file

Hi, We are running into very weird error on AIX. Target directory exists on NFS. We have one script runs every 5 mins on our system. This script is running for 5 years for now without any issuess. Followig is the snapshot of the script : stmt_cnt=$(ls -1 ${1}/${2}|wc -l) if ;... (7 Replies)
Discussion started by: himihir2000
7 Replies

6. Ubuntu

Need help with a weird sudo error.

I'm fairly new to unix and I was trying to change the name of my host and my user. I changed the name in /hostname using this: gksudo gedit /etc/hostname I then tried changing the name back but it still gave the same error: {env_reset,... (1 Reply)
Discussion started by: H3jck
1 Replies

7. Shell Programming and Scripting

Weird unbalanced quotes error

hi all, i am writing a wrapping script to burn subtitle into video file using transcode. I got this very weird error: code: inFile="movie.avi" subFile="sub.srt" outFile="movie_sub.avi" strExc="-i $inFile -x 'mplayer=-sub $subFile' -w $vidBR -o $outFile -y xvid" echo "transcode $strExc"... (2 Replies)
Discussion started by: tduccuong
2 Replies

8. Shell Programming and Scripting

Catch error from SFTP session

We have script running to SFTP some file to the remote server. The problem is the SFTP transfer returns an exit code of 0 even if there is permission error during file transfer, connection refuse (like when sftp server is down), thus, returning the status of the script as success. I was thinking... (3 Replies)
Discussion started by: The One
3 Replies

9. Shell Programming and Scripting

Unable to catch the output after core dump and bus error

I have a weird situation in which the binary dumps core and gives bus error. But before dumping the core and throwing the buss error, it gives some output. unfortunately I can't grep the output before core dump db2bfd -b test.bnd maxSect 15 Bus Error (core dumped) But if I do ... (4 Replies)
Discussion started by: rakeshou
4 Replies

10. Shell Programming and Scripting

For loop statement - catch error

I'm having a question about for loops. (bash) I have the following for example: for file in `ls *.txt` do read file ... done Now when there is a file present there is no problem, now when there is no file present I get the following output in my standard mail box : "No such... (4 Replies)
Discussion started by: lumdev
4 Replies
Login or Register to Ask a Question