For Programmers: Free Programming Magazines  


Home > Archive > Visual Studio > October 2004 > public variable inside of a class was lost at runtime









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author public variable inside of a class was lost at runtime
JohnL

2004-10-22, 3:58 pm

I am using Visual Studio 6.0 to develop a Win32 application for serial
communication.

I defined a public HANDLE variable for the communications device in my
serial communication class SCOMM. I debug the software and to my surprise,
sometimes this variable could not keep its value during the class life span,
and it changed its value to a different one. After I defined this HANDLE
variable to a global variable, this problem did not happen any more. I am
sure that the HANDLE variable was not defined somewhere else. Could anybody
help?

Thanks.

John





Victor Bazarov

2004-10-22, 3:58 pm

JohnL wrote:
> I am using Visual Studio 6.0 to develop a Win32 application for serial
> communication.
>
> I defined a public HANDLE variable for the communications device in my
> serial communication class SCOMM. I debug the software and to my surprise,
> sometimes this variable could not keep its value during the class life span,
> and it changed its value to a different one. After I defined this HANDLE
> variable to a global variable, this problem did not happen any more. I am
> sure that the HANDLE variable was not defined somewhere else. Could anybody
> help?


You probably have a serious buffer overrun problem that causes the
instance of your class to be affected. Set the debugger to break at
the time of the member variable changing, and run your program. It
will be slow as hell but it will stop when the overrun occurs. Of
course you could try to analyse the hell out of your code attempting
to find it without running. It's hard, though.

V
JohnL

2004-10-25, 4:01 pm

Thanks for your advice.

John


"Victor Bazarov" <v.Abazarov@comAcast.net> wrote in message
news:%231zXBPFuEHA.3984@TK2MSFTNGP09.phx.gbl...
> JohnL wrote:
surprise,[color=darkred]
span,[color=darkred]
am[color=darkred]
anybody[color=darkred]
>
> You probably have a serious buffer overrun problem that causes the
> instance of your class to be affected. Set the debugger to break at
> the time of the member variable changing, and run your program. It
> will be slow as hell but it will stop when the overrun occurs. Of
> course you could try to analyse the hell out of your code attempting
> to find it without running. It's hard, though.
>
> V



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com