Thread Subject: Unexpected behavior in debug mode

Subject: Unexpected behavior in debug mode

From: Todd

Date: 25 Nov, 2009 22:34:19

Message: 1 of 4

I seem to be getting some unexpected results in a program that I'm modifying (I'm not the original author).

I see three different things happen:
1. The program crashes when I run it normally.
2. When I insert a breakpoint (with no other changes) the program will run, but provide incorrect results.
3. If I step through the part of the code that I think has the problem line-by-line everything works fine and the program produces correct results.

I've seen something like this happen before when trying to talk to some external device, or using ActiveX. This is usually corrected by inserting a pause to correct any asynchronous behavior...unfortunately, that doesn't seem to be happening here. I'm processing data that is on my local machine (as opposed to the network, which could introduce some lag), and no external programs or devices are being called.

The program is too big and complicated to post here, but I was wondering if anyone else has seen anything like this before? What are some things I could try since the problem goes away in debug mode?

Subject: Unexpected behavior in debug mode

From: swetha

Date: 27 Nov, 2009 09:52:37

Message: 2 of 4

On Nov 26, 3:34 am, "Todd " <aeroan...@gmail.com> wrote:
> I seem to be getting some unexpected results in a program that I'm modifying (I'm not the original author).
>
> I see three different things happen:
> 1. The program crashes when I run it normally.  
> 2. When I insert a breakpoint (with no other changes) the program will run, but provide incorrect results.
> 3. If I step through the part of the code that I think has the problem line-by-line everything works fine and the program produces correct results.
>
> I've seen something like this happen before when trying to talk to some external device, or using ActiveX.  This is usually corrected by inserting a pause to correct any asynchronous behavior...unfortunately, that doesn't seem to be happening here. I'm processing data that is on my local machine (as opposed to the network, which could introduce some lag), and no external programs or devices are being called.
>
> The program is too big and complicated to post here, but I was wondering if anyone else has seen anything like this before?  What are some things I could try since the problem goes away in debug mode?

Hi,
Even i am experiencing the same problem.Have you got any solutions?
-swetha

Subject: Unexpected behavior in debug mode

From: Todd

Date: 27 Nov, 2009 18:17:19

Message: 3 of 4

swetha <swetha.bsharma@gmail.com> wrote in message <07d5c705-0a54-432c-bc86-b6b1581909de@u16g2000pru.googlegroups.com>...
> On Nov 26, 3:34?am, "Todd " <aeroan...@gmail.com> wrote:
> > I seem to be getting some unexpected results in a program that I'm modifying (I'm not the original author).
> >
> > I see three different things happen:
> > 1. The program crashes when I run it normally. ?
> > 2. When I insert a breakpoint (with no other changes) the program will run, but provide incorrect results.
> > 3. If I step through the part of the code that I think has the problem line-by-line everything works fine and the program produces correct results.
> >
> > I've seen something like this happen before when trying to talk to some external device, or using ActiveX. ?This is usually corrected by inserting a pause to correct any asynchronous behavior...unfortunately, that doesn't seem to be happening here. I'm processing data that is on my local machine (as opposed to the network, which could introduce some lag), and no external programs or devices are being called.
> >
> > The program is too big and complicated to post here, but I was wondering if anyone else has seen anything like this before? ?What are some things I could try since the problem goes away in debug mode?
>
> Hi,
> Even i am experiencing the same problem.Have you got any solutions?
> -swetha

The only thing I've got so far is that it seems like there is a variable that is not getting cleared (lots of sloppy use of global variables). As a result a while loop is being executed too many times. Again, I'm not sure why this would change when I'm in debug mode. If I rewrite the while loop as a for loop the program does not crash, but produces incorrect results.

Can you tell me something about how your program is structured?

My error is occurring in a while loop that is in a nested function. The function that calls the nested function is inside a for loop which is inside a while loop. I'm thinking the convoluted structure of the program has something to do with it. I'm curious what the commonalities are between your program and mine.

Subject: Unexpected behavior in debug mode

From: Todd

Date: 30 Nov, 2009 15:13:07

Message: 4 of 4

I can't believe I didn't try this earlier.

I fully shutdown my computer for about 20 minutes, then came back ran the program and everything was fine.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
debug Todd 25 Nov, 2009 17:39:06
breakpoint Todd 25 Nov, 2009 17:39:06
asynchronous Todd 25 Nov, 2009 17:39:06
error Todd 25 Nov, 2009 17:39:06
rssFeed for this Thread

Contact us at files@mathworks.com