See a different result in STEP than with BREAKPOINTS

  • Thread starter Thread starter Lee Gillie
  • Start date Start date
L

Lee Gillie

A surprising, and unexplained behavior was seen from a RELEASE build of
a VB application (essentially a console app). It processes thousands of
pages of text, and occasionally drops the first character of the first
line of the page. I really felt this was likely my own bug. In a DEBUG
build now I captured data from the page and wrote the result for each
page to the debug window. The result was consistent with the release
build, and occurred at the same pages, as expected. Next I let it run UP
TO THE PAGE of concern, and NOW stepped through in the debugger, so I
could see the problem. THIS TIME the character DID NOT DROP. I let it
step through to the DEBUG.WRITELINE (as described above), and it shows
the character was NOT DROPPED as well. The page reader works with
arrays of StringBuilder objects. I am certain there are lots of GC's
going on while running, but I try and reuse the same SB's for
efficiency, and set length to zero when reusing, to hopefully avoid
re-allocation overhead. So I am suspicious of StringBuilder.

Looking for any clues. I use VB.NET a lot, and have not seen this where
stepping through makes the code run differently. Maybe if others have,
and understand it, it will help me understand it well enough to mitigate
the problem. It probably still is my own bug, but the change in behavior
has served to confuse, not illuminate for me.

Thanks for anything anyone can share.

Best regards - Lee Gillie - Online Data Processing, Spokane, WA
 
Lee,

Just today I saw this behavior in an application someone asked me to debug.

When I executed the application I got the wrong results.

When I executed the application by stepping through it I got the correct
results.

What I discovered in this case what that the user was overriding the wrong
method in a class derived from a DataGrid. Once we fixed the code
everything was fine. Though the code did not stop the application from
running, it did not give the correct results when executed.

I have seen this maybe a half dozen times in the past three years. It has
always been bad code that caused this method for me.

Maybe you would like to post your code?

Hope this helps.


--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com
 
In the past I've had code which works correctly when stepped through but not
when run on its own. When you step through code, other things can occur
during the times when execution stops. Threads in parts of programs that you
don't control get a chance to process their events "in their own time",
which they don't get when the program is running uninterrupted. Sometimes a
call to DoEvents can help.

I'm not sure how that applies to your situation, but it might be helpful.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top