Click here to Skip to main content
15,889,830 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I have a bugs that will happen at random. Sometime when I run the program, the bugs will occur and suometime it does not. Mostly 9 out of 10 times the bugs would not occur. I have done some research online and I have found out that it is Heisenbugs. But for a bugs that would not happen at most of the time, no matter how I debug it wont appear. How can I solve the Heisenbugs? Any idea would be appreciated. Thank you.
Posted
Comments
syed shanu 8-Dec-14 1:46am    
Can you paste your code here.and tell us in which line do you get error.
Heard this term first time. I have to read about this. :)
syed shanu 8-Dec-14 2:03am    
here is Wikipedia link for Heisenbugs.
http://en.wikipedia.org/wiki/Heisenbug#Heisenbug
I belive that there is no meaning for this error for his problem.it seems in his program for some of input hes getting error for example we can say for 9 time he pass greater then 0 value for divid if suppos the 10th time if he pass the zero value to divide then he mgith get the error.
If he paste his error part of code hope it will be easy to find the solutions.

Like any kind of detective work you need to gather information about your running system first.

Try adding exception logging to track down the points to investigate more, like :
https://www.nuget.org/packages/log4net/[^]
or my article : Mini Drop-in Replacement for log4net[^]
 
Share this answer
 
1. Wiki - http://en.wikipedia.org/wiki/Heisenbug[^]
Quote:

Heisenbugs are usually resolved through very careful debugging. This works best if one is able to identify the approximate point in code where the bug is occurring. From there, solutions may be sought from inspection of nearby statements or analysis of process dumps.


Another technique is to examine logs, especially those produced by lint and lint-like tools.


For highly persistent heisenbugs, it may be necessary to analyze all possible traces of the program using static analysis techniques such as abstract interpretation to determine their cause.


2. Anti-Patterns and Worst Practices – Heisenbugs[^]
Quote:

As I mentioned before, a Heisenbug occurs when trying to check the state of an object. These types of defects are common with concurrency issues are present. Microsoft has put out a library to help diagnose these problems: CHESS (http://msdn.microsoft.com/en-us/devlabs/cc950526.aspx).


3. CHESS: Find and Reproduce Heisenbugs in Concurrent Programs[^]
 
Share this answer
 
Comments
Jamie888 8-Dec-14 2:31am    
Hi, may I know where can I download the CHESS? I have found no download link from the above links. Thank you.
It is a Open Source Project - http://chesstool.codeplex.com/

Go to Source Code Tab, you will get the DownLoad link.
Jamie888 8-Dec-14 20:51pm    
how can I install CHESS and how can I use it? I do not understand on how the software run. Thank you.
Even I have not tried.

But the installing information is dicumented at - http://chesstool.codeplex.com/documentation
I've experienced similar behaviour while working with interrupts, events (similar to interrupts) and timing related code. E.g. when you debug the issue is not there because you're slowing every step down. What you also can do instead of debugging is to use print commands, but this can also slow execution down. The other alternative is to add variables and save certain states or values of variables and only check them after the piece of suspect problem code has executed (using debugger or prints).

Debugging tools can also do some funky stuff... You can add a breakpoint on a variable to only trigger once it is a certain value (the faulty one). Step back, step forward, etc. Important with the debugger is to not hinder execution before the issue is created. Rather do it after and backtrack from there.

P.S. Memory issues can also present some strange looking bugs. But I guess with C# this is unlikely.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900