Local Variables not getting values back

S

Samant.Trupti

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
 
A

AnonMail2005

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.
 
P

Pascal J. Bourguignon

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.
 
S

Samant.Trupti

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.

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
 
P

Pascal J. 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.

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/
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,481
Members
44,900
Latest member
Nell636132

Latest Threads

Top