Serving the Quantitative Finance Community

 
User avatar
Cuchulainn
Topic Author
Posts: 20250
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

1/0 Detective Work

March 2nd, 2013, 10:03 am

Let's say you have a C program with lots of arrays and 1/0 run time error occurs.How would you find the source/root cause of the problem as quickly as possible (in the least amount of daylight hours)? Using F11 and F10 in VS Debugger is not necessarily what I mean.
Last edited by Cuchulainn on March 1st, 2013, 11:00 pm, edited 1 time in total.
 
User avatar
pcaspers
Posts: 30
Joined: June 6th, 2005, 9:49 am
Location: Germany

1/0 Detective Work

March 2nd, 2013, 12:29 pm

you really get a runtime error or some special value as a result indicating divison by zero (-1.#INF or something) ?if it is a runtime error, then running the code in debug mode should stop with a message giving the line where the error occured, I think.if not, then depends on the code, but maybe set conditional breakpoints in every line you divide something by some expression, conditioning on expression == 0.0 ?
Last edited by pcaspers on March 1st, 2013, 11:00 pm, edited 1 time in total.
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

1/0 Detective Work

March 2nd, 2013, 12:57 pm

The focus must be on the denominator and all the statements that assign a value to it, subtract a value from it, or multiply it by a coefficient.How about bisection search backwards from the line with the error?
 
User avatar
Polter
Posts: 1
Joined: April 29th, 2008, 4:55 pm

1/0 Detective Work

March 2nd, 2013, 2:43 pm

If it's as written (1/0, i.e., ints), the behavior is undefined; Clang's upcoming features -fsanitize=integer or -fsanitize=undefined might be of help: http://blog.regehr.org/archives/905If it's floating-point, see "Exceptional floating point" by Bruce Dawson: http://gamasutra.com/view/news/169203/E ... int.phpSee also: http://stackoverflow.com/questions/3105 ... c-language
 
User avatar
dd3
Posts: 4
Joined: June 8th, 2010, 9:02 am

1/0 Detective Work

March 2nd, 2013, 2:45 pm

QuoteOriginally posted by: CuchulainnLet's say you have a C program with lots of arrays and 1/0 run time error occurs.How would you find the source/root cause of the problem as quickly as possible (in the least amount of daylight hours)? Using F11 and F10 in VS Debugger is not necessarily what I mean.Use assertions for _DEBUG mode