[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 950
  • Last Modified:

std string user breakpoint called, _CrtIsValidHeapPointer

Hi guys,

I've got a simple console app in VC6 that uses stl strings.
Whenever a string gets destroyed, I get an abort.
Looks like the heap pointer doesn't exist anymore...

I've seen other postings with similar issues, however none of those solutions helped :(

The app is a simple oracle OCCI application.
As soo as I make a call to get a string from a resultset, and the resulting string gets popped off the stack, the abort occurs.
I.e. right after
{
 m_Cursor->getString(1).c_str();
}

I'm not mixing old std C++ and ansi std C++, so that shouldn't be the problem.

Projects options:
I tried 'Mulithreaded DLL' (/MD) , 'Debug Multithreaded DLL' (/MDd) and 'Debug Multithreaded' (/MTd) to get the program to link with the right libs.
0
Jaco_Kruger
Asked:
Jaco_Kruger
  • 2
  • 2
  • 2
  • +1
1 Solution
 
mrblueCommented:
I've never noticed any problem with strings in ATL (VC 6.0).
What is "getString()", is it your method ?
0
 
mrblueCommented:
getString() - how is it implemented ?
0
 
jkrCommented:
>>Whenever a string gets destroyed, I get an abort.

You are returning the string from a DLL or mixing debug/realease modules? If so, you encountered that memory has to be freed in the module it was allocated in. Passing template classes (such as a std::string) over module boundaries is not a good idea for these reasons.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Jaco_KrugerAuthor Commented:
getString is a method inside an oracle library that i link statically to (oraocci9.lib).
According to Oracle documentation the signature is 'string getString(int);'
So it always creates a new string object upon returning.
I'm compiling my code in debug mode on windows and we use a release version for unix platforms. But can mixing a release library with debug code cause the heap to become corrupt?
0
 
jkrCommented:
>>But can mixing a release library with debug code cause the heap to become corrupt?

You aren't experiencing a corrupted heap. Debug and Release versions use different heaps, each has their own. If you try to deallocate memory in Debug that was allocated in Release, the pointer is invalid for that heap that tries to free it. If you run all modules either as Debug or Release (with '(Debug) Mulithreaded DLL'!), there shouldn't be a problem.
0
 
tushar_compCommented:
hi,

i have done these things with excel sheet , db connection with excel sheet
using com object of ado in c++ .. if i m not making any mistake that is what ur doing with oracle..

just go throgh the following link
see the get method defined in the sample u will get ur ans..

http://www.codeguru.com/cpp/data/mfc_database/ado/article.php/c6729/

if its useful let me know
Tushar
0
 
Jaco_KrugerAuthor Commented:
Jeez, Got it fixed.
Added msvcprt.lib in my 'inclusion' library list, and
added libcmtd.lib in my 'ignore' library list.

Looks like even though I'm compiling debug code, I have to link with msvcprt.lib (which is the release version), if I'm using an external (release version) library like oraocci9.lib.

jkr gets it for being closest ;)

Thanks guys.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now