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. Heap corruption problem after AfxBeginThread?

Heap corruption problem after AfxBeginThread?

Scheduled Pinned Locked Moved C / C++ / MFC
helpdebuggingc++performancequestion
6 Posts 4 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.
  • B Offline
    B Offline
    bosfan
    wrote on last edited by
    #1

    Hi, i need some help to solve this problem after create of worker thread. When i create a worker thread i receive this error message:

    Windows has triggered a breakpoint in myprog.exe.

    This may be due to a corruption of the heap, which indicates a bug in myprog.exe or any of the DLLs it has loaded.

    This is the code snippet:

    // create Thread:
    CWinThread* cmythr= AfxBeginThread(controlfunc,params, THREAD_PRIORITY_HIGHEST, 0,CREATE_SUSPENDED,0);
    if(NULL != cmythr)
    {
    cmythr->ResumeThread();
    }

    but after maybe 10 seconds i receive this error message: and the debugger show in this code in the file thrdcore.cpp:

    // first -- check for simple worker thread
    DWORD nResult = 0;
    if (pThread->m_pfnThreadProc != NULL)
    {
    nResult = (*pThread->m_pfnThreadProc)(pThread->m_pThreadParams);
    ASSERT_VALID(pThread);
    }

    A thing what make me confuse is that i cant find this position with memory allocation, i do nothing like this in this Function? No parameter is NULL, what i'm doing wrong? Any help is welcome Thanks bosfan

    S L S 4 Replies Last reply
    0
    • B bosfan

      Hi, i need some help to solve this problem after create of worker thread. When i create a worker thread i receive this error message:

      Windows has triggered a breakpoint in myprog.exe.

      This may be due to a corruption of the heap, which indicates a bug in myprog.exe or any of the DLLs it has loaded.

      This is the code snippet:

      // create Thread:
      CWinThread* cmythr= AfxBeginThread(controlfunc,params, THREAD_PRIORITY_HIGHEST, 0,CREATE_SUSPENDED,0);
      if(NULL != cmythr)
      {
      cmythr->ResumeThread();
      }

      but after maybe 10 seconds i receive this error message: and the debugger show in this code in the file thrdcore.cpp:

      // first -- check for simple worker thread
      DWORD nResult = 0;
      if (pThread->m_pfnThreadProc != NULL)
      {
      nResult = (*pThread->m_pfnThreadProc)(pThread->m_pThreadParams);
      ASSERT_VALID(pThread);
      }

      A thing what make me confuse is that i cant find this position with memory allocation, i do nothing like this in this Function? No parameter is NULL, what i'm doing wrong? Any help is welcome Thanks bosfan

      S Offline
      S Offline
      Sivaraman Dhamodharan
      wrote on last edited by
      #2

      Answer these two questions. 1) Provide the prototype of your function controlfunc> 2) What do you pass as params?

      Programming Article

      1 Reply Last reply
      0
      • B bosfan

        Hi, i need some help to solve this problem after create of worker thread. When i create a worker thread i receive this error message:

        Windows has triggered a breakpoint in myprog.exe.

        This may be due to a corruption of the heap, which indicates a bug in myprog.exe or any of the DLLs it has loaded.

        This is the code snippet:

        // create Thread:
        CWinThread* cmythr= AfxBeginThread(controlfunc,params, THREAD_PRIORITY_HIGHEST, 0,CREATE_SUSPENDED,0);
        if(NULL != cmythr)
        {
        cmythr->ResumeThread();
        }

        but after maybe 10 seconds i receive this error message: and the debugger show in this code in the file thrdcore.cpp:

        // first -- check for simple worker thread
        DWORD nResult = 0;
        if (pThread->m_pfnThreadProc != NULL)
        {
        nResult = (*pThread->m_pfnThreadProc)(pThread->m_pThreadParams);
        ASSERT_VALID(pThread);
        }

        A thing what make me confuse is that i cant find this position with memory allocation, i do nothing like this in this Function? No parameter is NULL, what i'm doing wrong? Any help is welcome Thanks bosfan

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        It's impossible to guess what may be wrong with the information you provided. You should use your debugger to set some breakpoints in your code, and check the actual values of the various parameters at the time of the failure. You can also use the stacktrace to see which functions have been called recently.

        One of these days I'm going to think of a really clever signature.

        B 1 Reply Last reply
        0
        • L Lost User

          It's impossible to guess what may be wrong with the information you provided. You should use your debugger to set some breakpoints in your code, and check the actual values of the various parameters at the time of the failure. You can also use the stacktrace to see which functions have been called recently.

          One of these days I'm going to think of a really clever signature.

          B Offline
          B Offline
          bosfan
          wrote on last edited by
          #4

          Hi, thanks for reply i try to solve this in this way. best regards bosfan

          1 Reply Last reply
          0
          • B bosfan

            Hi, i need some help to solve this problem after create of worker thread. When i create a worker thread i receive this error message:

            Windows has triggered a breakpoint in myprog.exe.

            This may be due to a corruption of the heap, which indicates a bug in myprog.exe or any of the DLLs it has loaded.

            This is the code snippet:

            // create Thread:
            CWinThread* cmythr= AfxBeginThread(controlfunc,params, THREAD_PRIORITY_HIGHEST, 0,CREATE_SUSPENDED,0);
            if(NULL != cmythr)
            {
            cmythr->ResumeThread();
            }

            but after maybe 10 seconds i receive this error message: and the debugger show in this code in the file thrdcore.cpp:

            // first -- check for simple worker thread
            DWORD nResult = 0;
            if (pThread->m_pfnThreadProc != NULL)
            {
            nResult = (*pThread->m_pfnThreadProc)(pThread->m_pThreadParams);
            ASSERT_VALID(pThread);
            }

            A thing what make me confuse is that i cant find this position with memory allocation, i do nothing like this in this Function? No parameter is NULL, what i'm doing wrong? Any help is welcome Thanks bosfan

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Could be wrong here but I think you have to call a Macro just after the thread enters in order to set it up properly, google it, it is well known. (Had this years ago, and havent done any user mode for ages. :) )

            1 Reply Last reply
            0
            • B bosfan

              Hi, i need some help to solve this problem after create of worker thread. When i create a worker thread i receive this error message:

              Windows has triggered a breakpoint in myprog.exe.

              This may be due to a corruption of the heap, which indicates a bug in myprog.exe or any of the DLLs it has loaded.

              This is the code snippet:

              // create Thread:
              CWinThread* cmythr= AfxBeginThread(controlfunc,params, THREAD_PRIORITY_HIGHEST, 0,CREATE_SUSPENDED,0);
              if(NULL != cmythr)
              {
              cmythr->ResumeThread();
              }

              but after maybe 10 seconds i receive this error message: and the debugger show in this code in the file thrdcore.cpp:

              // first -- check for simple worker thread
              DWORD nResult = 0;
              if (pThread->m_pfnThreadProc != NULL)
              {
              nResult = (*pThread->m_pfnThreadProc)(pThread->m_pThreadParams);
              ASSERT_VALID(pThread);
              }

              A thing what make me confuse is that i cant find this position with memory allocation, i do nothing like this in this Function? No parameter is NULL, what i'm doing wrong? Any help is welcome Thanks bosfan

              S Offline
              S Offline
              Stephen Hewitt
              wrote on last edited by
              #6

              Try enabling the "page heap" for your application. It can be a little painful but it often finds the cause of problems like yours.

              Steve

              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