Re: URGENT: Local variables dissapear after unmanaged function call
- From: "Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx>
- Date: Thu, 21 Jun 2007 13:22:51 -0500
"Papa.Coen" <papa.coen@xxxxxxxxx> wrote in message
news:1182424110.527494.72550@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Right after I call a function in an external dll, some of my local
variables, not used in the call (!!!) in any way, are 'null' right
after the call.
(Pseudo)code
[Dllimport ...]
public static ... calc(...)
StringBuilder sB = new StringBuilder("hello");
String tmp = "I'm on my own";
calc(ref tmp);
// sB = null here!
What's happening here!?
Looks like a classic buffer overrun. Were you supposed to pass a reference
to a String tracking handle? Probably not. So the function took the space
you gave it, just big enough for a tracking handle, and wrote beyond that.
.
- Follow-Ups:
- References:
- URGENT: Local variables dissapear after unmanaged function call
- From: Papa.Coen
- URGENT: Local variables dissapear after unmanaged function call
- Prev by Date: Re: How do I pinvoke this function?
- Next by Date: Re: a case for multiple inheritance
- Previous by thread: Re: URGENT: Local variables dissapear after unmanaged function call
- Next by thread: Re: URGENT: Local variables dissapear after unmanaged function call
- Index(es):