views:

524

answers:

1

I am embedding perl in a C++ application that uses Smartheap. Regardless of whether I compile the perl to use its own malloc or the system's I get a bunch of error mem___bad_pointer dialogs. It seems to work fine when I just click "ok" and ignore the errors, but obviously I need to actually solve the problem.

Do I maybe need to compile SmartHeap into my perl build? Is that even feasible?

Below is the only documentation page about mem__bad_pointer's I could find, but I am no closer to solving the problem. I do not understand how or where perl and Smartheap are conflicting with each other. Any pointers appreciated.

  • The pointer was allocated by a memory manager other than SmartHeap, such as from another DLL or EXE, or from the compiler runtime library. Examine your map file to see that the SmartHeap version of malloc, _fmalloc/farmalloc, or operator new is being linked in.
  • The pointer is “wild” (uninitialized), is allocated on the stack (local variable), or is otherwise invalid.
  • The pointer was previously freed. If SmartHeap has freed the page from which the pointer was originally allocated, SmartHeap won’t be able to detect that it’s a double free. However, SmartHeap will report the invalid pointer. Use dbgMemDeferFreeing to catch this type of bug.
  • The pointer was incremented or decremented since the time of allocation.
  • For 16-bit x86, the pointer was cast to a near pointer after allocation, in which case the segment portion of the pointer has been lost.
  • The memory pool from which the pointer was allocated has been freed, or SmartHeap has been unregistered from the task.
  • The task from which the pointer was allocated has terminated (see section B.4).
A: 

Without seeing the code it is hard to debug the problem. Perhaps you are allocating memory using both smartheap and the regular memory manager. this can be caused when you allocat memory in a dll build without smart heap.

Depending on your code, the allocation could be fine and you may be writing outside the allcoated memory area.

David