Problem with usage of STL release Dll with debug application

  • Thread starter Voronkov Konstantin
  • Start date
V

Voronkov Konstantin

Hello, All!

I have following problem with std::string class.
I exproted class from dll which has function which returns
std::string.

I compiled dll in *release* configuration
(using Multithreaded Dll run-time library)

I imported class in application and called function which returns
std:string. The application is compiled in debug configuration
with (Debug Multithreaded Dll run-time library) I have heap corruption
problem, here is the stack:

NTDLL! 77f43847()
NTDLL! 77f78135()
KERNEL32! 77e6cd3c()
_CrtIsValidHeapPointer(const void * 0x00322e28) line 1697
_free_dbg_lk(void * 0x00322e28, int 1) line 1044 + 9 bytes
_free_dbg(void * 0x00322e28, int 1) line 1001 + 13 bytes
free(void * 0x00322e28) line 956 + 11 bytes
operator delete(void * 0x00322e28) line 7 + 10 bytes
std::allocator<char>::deallocate(void * 0x00322e28, unsigned int 33)
line 64 + 16 bytes
std::basic_string said:
::_Tidy(unsigned char 1) line 592
std::basic_string said:
::~basic_string<char,std::char_traits<char>,std::allocator<char> >()
line 59 + 17 bytes
main(int 1, char * * 0x00342d50) line 9 + 18 bytes
mainCRTStartup() line 338 + 17 bytes
KERNEL32! 77e4f38c()


Does that mean that I can not link release library to debug
application?

Does anyone knows the workarond for my problem?
Mayve I did someting wrong?
Maybe some external STL library helps me, aka STL Port?

I'm using MS VS Compiler with sp5.


Here is the code of dll.h: ########################

#ifdef TESTDLL2_EXPORTS
#define TESTDLL2_API __declspec(dllexport)
#else
#define TESTDLL2_API __declspec(dllimport)
#endif

#include <string>

class TESTDLL2_API Foo
{
public:
std::string toString()const;
};


Here is the code of dll.cpp: ########################

#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows
headers
#include <windows.h>

#include "stdafx.h"
#include "TestDll2.h"

BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call,
LPVOID lpReserved)
{
return TRUE;
}

std::string Foo::toString()const
{
std::string string = "-";
std::string sStringEnd = ":R";
return domainTI_String + sStringEnd;
}

Here is the code of application.cpp: ########################
#include <TestDll2.h>

int main(int argc, char* argv[])
{
Foo foo;
std::string str = foo.toString();
return 0;
}


Best Regards,
Voronkov Konstantin
 
M

Mike Smith

Voronkov said:
Does that mean that I can not link release library to debug
application?

You really should ask this on an MSVC programming newsgroup, but
briefly: yes, mixing the use of release and debug versions of MSVCRT.DLL
can certainly cause this kind of problem.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top