![]() |
Local Variables not getting values back
Hi All,
I am facing a strange problem.. I am calling a function func2 from func1. Before calling func2 all the local variables in func1 looks fine and has their respective values. When function returns back from func2 to func1 all the local variables in func1 has values 0xfdfdfd. Can somebody please explain me what is happening and what is the solution for this? Thanks Trupti |
Re: Local Variables not getting values back
> Hi All,
> > * I am facing a strange problem.. > I am calling a function func2 from func1. *Before calling func2 all > the local variables in func1 looks fine and has their respective > values. *When function returns back from func2 to func1 all the local > variables in func1 has values 0xfdfdfd. > *Can somebody please explain me what is happening and what is the > solution for this? Post some code so we can take a look at it. |
Re: Local Variables not getting values back
On Mon, 16 Jun 2008 06:41:18 -0700, Samant.Trupti@gmail.com wrote:
> Hi All, > > I am facing a strange problem.. > I am calling a function func2 from func1. Before calling func2 all the > local variables in func1 looks fine and has their respective values. > When function returns back from func2 to func1 all the local variables > in func1 has values 0xfdfdfd. > Can somebody please explain me what is happening and what is the > solution for this? Post code. http://www.parashift.com/c++-faq-lit...t.html#faq-5.8 -- Lionel B |
Re: Local Variables not getting values back
"Samant.Trupti@gmail.com" <Samant.Trupti@gmail.com> writes:
> Hi All, > > I am facing a strange problem.. > I am calling a function func2 from func1. Before calling func2 all > the local variables in func1 looks fine and has their respective > values. When function returns back from func2 to func1 all the local > variables in func1 has values 0xfdfdfd. > Can somebody please explain me what is happening and what is the > solution for this? There's probably a "buffer overflow" or some other kind of overrun in the local variables of func2. In the usual processors, the stack grows downward, and the local variables are allocated on the stack. So the local variables of func2 are stored before the the local variables of func1, and if you write beyond the bounds of the local variables of func2, you can erase the frame pointers, the return addresses and the local variables of the calling procedures. The solution would be to debug func2. -- __Pascal Bourguignon__ |
Re: Local Variables not getting values back
On Jun 16, 7:34*pm, p...@informatimago.com (Pascal J. Bourguignon)
wrote: > "Samant.Tru...@gmail.com" <Samant.Tru...@gmail.com> writes: > > Hi All, > > > * I am facing a strange problem.. > > I am calling a function func2 from func1. *Before calling func2 all > > the local variables in func1 looks fine and has their respective > > values. *When function returns back from func2 to func1 all the local > > variables in func1 has values 0xfdfdfd. > > *Can somebody please explain me what is happening and what is the > > solution for this? > > There's probably a "buffer overflow" or some other kind of overrun in > the local variables of func2. *In the usual processors, the stack > grows downward, and the local variables are allocated on the stack. > So the local variables of func2 are stored before the the local > variables of func1, and if you write beyond the bounds of the local > variables of func2, you can erase the frame pointers, the return > addresses and the local variables of the calling procedures. > > The solution would be to debug func2. > > -- > __Pascal Bourguignon__ Thank you for quick reply for my query. It is not possible for me to post code. It is a big application and lots of variables. I will try to debug it according your suggestions. Please post me some more suggestions if any. Trupti |
Re: Local Variables not getting values back
"Samant.Trupti@gmail.com" <Samant.Trupti@gmail.com> writes:
> Thank you for quick reply for my query. It is not possible for me to > post code. It is a big application and lots of variables. > I will try to debug it according your suggestions. Please post me > some more suggestions if any. Well, given this kind of behavior (of your program), it might be very useful for you to run it under valgrind. You will probably find a lot of bugs with valgrind. http://valgrind.org/ -- __Pascal Bourguignon__ |
| All times are GMT. The time now is 08:07 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.