Memory error with funcs that return char*
- From: Chuck C <chuckc@xxxxxxxxx>
- Date: Mon, 30 Oct 2006 12:32:27 -0800
I have an odd error comming up that does not seem to actually cause a
problem (everything seems to work fine) but it concerns me.
Error:
----------------------------------------
HEAP[appname.exe]: Invalid Address specified to RtlFreeHeap( 00170000,
10015988 )
Windows has triggered a breakpoint in appname.exe.
This may be due to a corruption of the heap, and indicates a bug in
appname.exe or any of the DLLs it has loaded.
The output window may have more diagnostic information
----------------------------------------
I have a Win32 C application that loads up the .NET CLR via
CorBindToRuntimeEx(). I creates an instance of a C# class that uses
DllImport statements to link back into a Win32 C DLL that has several
helper functions.
The only time that this error comes up is when I run in debug mode AND when
I have VS2005 startup the Win32 appplication. If I have VS2005 startup the
C# DLL and tell it to launch (ie. Start External Program) the Win32
application it works fine. It only seems to show up when I have a helper
(Win32 C DLL) function that returns a char*. If they return int, float,
etc. I do not get this error.
Is there something special with char*'s being returned from C code when
called via C# and DllImport?
Sorry for the lack of info - it is one of those hard to describe setups!
Here is what it looks like from a flow standpoint:
(Win32 C console app)
-> (loads up .NET CLR)
-> (creates instance of class within C# DLL)
-> (C# class makes calls to Win32 C DLL)
Here is a sample function I am using that just returns a hard coded string:
Win32 C DLL function def (cfile.dll):
extern "C" __declspec(dllexport) char* __stdcall TEST( )
{
return "hello world from TEST() function";
}
C# DllImport:
[DllImport("cfile.dll")]
public static extern String TEST();
Not sure what else to say... cannot really post sample projects so
hopefully someone can help without 'em!
Thanks.
.
- Follow-Ups:
- Re: Memory error with funcs that return char*
- From: Mattias Sjögren
- Re: Memory error with funcs that return char*
- Prev by Date: An unhandled non-continuable exception was thrown during process load
- Next by Date: Re: Memory error with funcs that return char*
- Previous by thread: An unhandled non-continuable exception was thrown during process load
- Next by thread: Re: Memory error with funcs that return char*
- Index(es):
Relevant Pages
|