Function Parameters Change when function called?! 
Author Message
 Function Parameters Change when function called?!

I have a display feature that is not working properly.  In
troubleshooting the problem, I traced the program to a function call,
and surprise of surprises -- the passed values change from the calling
function to the called function, with nothing in between that should
alter the values!  This problem is occurring in long standing code that
has previously proven itself to function correctly.  

This problem popped up after I added some new code to the program.
Something I added compiles, links and allows the program to run, but
causes the problem I am viewing above.

Any ideas or suggestion as to what I added that may be causing this?  Or
what routines in VC libraries that may be causing this?

I am using VC++v5.0 under NT4.0 on DEC Alpha.

TIA,
Jeff



Wed, 08 Oct 2003 02:37:07 GMT  
 Function Parameters Change when function called?!
Show the code you added otherwise I do not think too many people could
answer your question.

If I had to guess at what you did it would be
1) You added code for creating a thread and sent in a this pointer.  The
object reference is fine in the call back but all references to the member
data are gone.  Could be from rebasing of a dll, . hmm... alot of other
things.

2) You instantiated a char * with no initialization and it is over running
the buffer and trashing your memory segments.

I'm sure others could add other possibilities.

Steven Szelei


Quote:
> I have a display feature that is not working properly.  In
> troubleshooting the problem, I traced the program to a function call,
> and surprise of surprises -- the passed values change from the calling
> function to the called function, with nothing in between that should
> alter the values!  This problem is occurring in long standing code that
> has previously proven itself to function correctly.

> This problem popped up after I added some new code to the program.
> Something I added compiles, links and allows the program to run, but
> causes the problem I am viewing above.

> Any ideas or suggestion as to what I added that may be causing this?  Or
> what routines in VC libraries that may be causing this?

> I am using VC++v5.0 under NT4.0 on DEC Alpha.

> TIA,
> Jeff



Wed, 08 Oct 2003 04:32:58 GMT  
 Function Parameters Change when function called?!

Quote:

> Show the code you added otherwise I do not think too many people could
> answer your question.

I added around 20 pages worth, printed out.  None of it was anything
very technical, viz, all I used are MFC routines such as CArray,
CTypedPtrs, etc to read in some data, manipulate it and put the results
to screen.  I don't use character pointers, rather CArrays and CStrings,
however, other uninitialized pointers could be an issue.  Is there any
way to see evidence that they are a problem?

Thanks for the response,
Jeff

Quote:

> If I had to guess at what you did it would be
> 1) You added code for creating a thread and sent in a this pointer.  The
> object reference is fine in the call back but all references to the member
> data are gone.  Could be from rebasing of a dll, . hmm... alot of other
> things.

> 2) You instantiated a char * with no initialization and it is over running
> the buffer and trashing your memory segments.

> I'm sure others could add other possibilities.

> Steven Szelei



> > I have a display feature that is not working properly.  In
> > troubleshooting the problem, I traced the program to a function call,
> > and surprise of surprises -- the passed values change from the calling
> > function to the called function, with nothing in between that should
> > alter the values!  This problem is occurring in long standing code that
> > has previously proven itself to function correctly.

> > This problem popped up after I added some new code to the program.
> > Something I added compiles, links and allows the program to run, but
> > causes the problem I am viewing above.

> > Any ideas or suggestion as to what I added that may be causing this?  Or
> > what routines in VC libraries that may be causing this?

> > I am using VC++v5.0 under NT4.0 on DEC Alpha.

> > TIA,
> > Jeff



Wed, 08 Oct 2003 06:59:13 GMT  
 Function Parameters Change when function called?!
Such things are not easy. You might be lucky by having a very narrow area to
suspect as being affected. That is, you suspect that the memory is being
clobbered somewhere between the calling and the called function. So you
could put a breakpoint on the call and when it is executed, first verify
that the parameters are correct then set another breakpoint that breaks when
an item or area of memory changes. Do you know what I mean? If you are
lucky, you will find the problem quickly, or at least get a big clue.


Quote:


> > Show the code you added otherwise I do not think too many people could
> > answer your question.

> I added around 20 pages worth, printed out.  None of it was anything
> very technical, viz, all I used are MFC routines such as CArray,
> CTypedPtrs, etc to read in some data, manipulate it and put the results
> to screen.  I don't use character pointers, rather CArrays and CStrings,
> however, other uninitialized pointers could be an issue.  Is there any
> way to see evidence that they are a problem?

> Thanks for the response,
> Jeff

> > If I had to guess at what you did it would be
> > 1) You added code for creating a thread and sent in a this pointer.  The
> > object reference is fine in the call back but all references to the
member
> > data are gone.  Could be from rebasing of a dll, . hmm... alot of other
> > things.

> > 2) You instantiated a char * with no initialization and it is over
running
> > the buffer and trashing your memory segments.

> > I'm sure others could add other possibilities.

> > Steven Szelei



> > > I have a display feature that is not working properly.  In
> > > troubleshooting the problem, I traced the program to a function call,
> > > and surprise of surprises -- the passed values change from the calling
> > > function to the called function, with nothing in between that should
> > > alter the values!  This problem is occurring in long standing code
that
> > > has previously proven itself to function correctly.

> > > This problem popped up after I added some new code to the program.
> > > Something I added compiles, links and allows the program to run, but
> > > causes the problem I am viewing above.

> > > Any ideas or suggestion as to what I added that may be causing this?
Or
> > > what routines in VC libraries that may be causing this?

> > > I am using VC++v5.0 under NT4.0 on DEC Alpha.

> > > TIA,
> > > Jeff



Wed, 08 Oct 2003 10:01:56 GMT  
 Function Parameters Change when function called?!
is it going to the right function ? (ie. check the code pointer and make
sure the function ptr is good). if so, then check the number and type of
parameters passed to the function. may be you are passing less number of
parameters or different types of parameters than is expected ? is this
crashing in release version and runs ok in debug ?

sCaLLioN


Quote:
> I have a display feature that is not working properly.  In
> troubleshooting the problem, I traced the program to a function call,
> and surprise of surprises -- the passed values change from the calling
> function to the called function, with nothing in between that should
> alter the values!  This problem is occurring in long standing code that
> has previously proven itself to function correctly.

> This problem popped up after I added some new code to the program.
> Something I added compiles, links and allows the program to run, but
> causes the problem I am viewing above.

> Any ideas or suggestion as to what I added that may be causing this?  Or
> what routines in VC libraries that may be causing this?

> I am using VC++v5.0 under NT4.0 on DEC Alpha.

> TIA,
> Jeff



Wed, 08 Oct 2003 22:44:20 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Function Parameters Change when function called?!

2. Function Parameters Change when function called?!

3. function parameters and return values aren't changed by function call

4. Call a function in a function with name of a function as parameter

5. Question : A generic function to retrieve the call parameters of a function

6. Calling DLL functions without known function name, parameter-list until run-time

7. Question : A generic function to retrieve the call parameters of a function

8. Condition breakpoints and function calls and function calls in Immediate window

9. Calling an unmanaged DLL function that uses a std::string parameter

10. calling C++ function from Fortran: parameter passing

11. Calling Managed C++ function from C# with array parameters

12. Calling Managed C++ function from C# with array parameters

 

 
Powered by phpBB® Forum Software