Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Error: _CrtIsValidHeapPointer(pUserData)

Error: _CrtIsValidHeapPointer(pUserData)

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpdelphidebuggingworkspace
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    suninwater
    wrote on last edited by
    #1

    Hi,guys: I got a serious error when developing a DLL for my teammates' DELPHI application. Any help is appreciated. Environment: Windows2000 AS, VC++6.0SP5. Related code: typedef struct _tag_MyPackage { int len; char *data; }MyPackage; When I got some data, MyPackage *mp = new MyPackage; mp->data = new char[length of the data] memcpy(mp->data, ...); EnterCriticalSection(&m_cs); mylist.pushback(mp); LeaveCriticalSection(&m_cs); When something happens, below code is executed in another thread, EnterCriticalSection(&m_cs); iterator = mylist.begin(); MyPackage *mp = *iterator; memcpy(A_Pointer_Defined_Before, mp->data, mp->len); if (mp != NULL && mp->data != NULL) { delete [](mp->data); delete mp; } mylist.erase(iterator); LeaveCriticalSection(&m_cs); return; My program runs prefectly in much time, but, in some condition it fails at this line. delete [](mp->data); The error message: Program:\work\myapp\test.exe File: dbgheap.c Line:1044 Expression: _CrtIsValidHeapPointer(pUserData) For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts. (Press Retry to debug the application) And I also found it fails only when the length of data is a bit long, say, 220000bytes. Some other short length such as 100bytes/1000bytes/50000bytes are all successfully performed. Thanks for your patience and any replies.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups