0

I am currently using Visual Studio 2010, under debug mode x64 on a windows 8(64bit). I have this program that I am trying to debug but when I set a breakpoint, and it gets hit, the output of the function is different from the output when I don't have the breakpoint set. I am unsure what is going on, (the only thing I can think of is that the threads are acting differently when I have a break point set, if that's even a possibility).

Has anyone run into this kind of situation and how were you able to solve this issue?

If you need anymore information, let me know and I'll do my best.

masotann
  • 901
  • 10
  • 29
  • 5
    Can you show the code ? – Kurubaran Jun 03 '13 at 17:43
  • 3
    that's a very distinct possibility. When the debugger is running, you've influenced a LOT of timing and threading behavior. When the debugger is running (by default), you also get different memory management behavior as well. However, I don't know that having a breakpoint set or not should influence anything by itself. but the difference between run and debug is very real. – John Gardner Jun 03 '13 at 17:45
  • unless you have programmed the "breakpoint" to change values ​​or structures, you should not have a different result with or without breakpoint. +1 for @Coder – PiLHA Jun 03 '13 at 17:46
  • I came across similar issue when i tried to generate random numbers. – Kurubaran Jun 03 '13 at 17:47
  • @Coder, I'm sorry the place I'm trying to debug is part of a very large program and it's not very practical to post it here. However, how did you solve the similar issue you came across when generating random numbers? – masotann Jun 03 '13 at 17:50
  • 1
    If multithreading is involved, you will often get this happening. As for the random numbers: Perhaps he was creating a new `Random` in a loop rather than reusing a `Random`, which causes the same number to be generated because it uses `Environment.TickCount` as a seed (and `Environment.TickCount` only changes once every few milliseconds). – Matthew Watson Jun 03 '13 at 17:50
  • @Calpis i had this issue http://stackoverflow.com/questions/767999/random-number-generator-only-generating-one-random-number – Kurubaran Jun 03 '13 at 17:55
  • 1
    This happens to me a lot when I set a conditional breakpoint like `myVar = 5` instead of `myVar == 5`. It's a very subtle error. – Bobson Jun 03 '13 at 18:06
  • This is kind of silly mistake..So the function in question was invoked upon mousedown/mouseup. When I did not have the breakpoint set, the mousedown/mouseup went through the function, however, when I had the breakpoint set, the mousedown was registered but the mouseup didn't get registered because the mouseup was done while debugging. Sorry for the dumb mistake everyone! – masotann Jun 03 '13 at 18:23

1 Answers1

1

This is kind of silly mistake..So the function in question was invoked upon mousedown/mouseup. When I did not have the breakpoint set, the mousedown/mouseup went through the function, however, when I had the breakpoint set, the mousedown was registered but the mouseup didn't get registered because the mouseup was done while debugging. Sorry for the dumb mistake everyone!

masotann
  • 901
  • 10
  • 29