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. Re: Error in plex.cpp, line 44

Re: Error in plex.cpp, line 44

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++question
4 Posts 3 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.
  • M Offline
    M Offline
    mla154
    wrote on last edited by
    #1

    Hello, I'm receiving a windows message box (actual name of EXE omitted):     First-chance exception in ______.exe: 0xC0000005: Access Violation Possible deallocation error?  Any other ideas what the problem may be?  Any help is appreciated.  The disassembly code is shown below (crash at line 44).

    38: void CPlex::FreeDataChain() // free this one and links
    39: {
    00479931 test ecx,ecx
    00479933 je CPlex::FreeDataChain+15h (00479946)
    00479935 push esi
    40: CPlex* p = this;
    41: while (p != NULL)
    42: {
    43: BYTE* bytes = (BYTE*) p;
    44: CPlex* pNext = p->pNext;
    00479936 mov esi,dword ptr [ecx]
    45: delete[] bytes;
    00479938 push ecx
    00479939 call operator delete (0047f53d)
    0047993E pop ecx
    0047993F test esi,esi
    46: p = pNext;
    00479941 mov ecx,esi
    00479943 jne CPlex::FreeDataChain+5 (00479936)
    00479945 pop esi
    47: }
    48: }

    Regards, Mike

    S B M 3 Replies Last reply
    0
    • M mla154

      Hello, I'm receiving a windows message box (actual name of EXE omitted):     First-chance exception in ______.exe: 0xC0000005: Access Violation Possible deallocation error?  Any other ideas what the problem may be?  Any help is appreciated.  The disassembly code is shown below (crash at line 44).

      38: void CPlex::FreeDataChain() // free this one and links
      39: {
      00479931 test ecx,ecx
      00479933 je CPlex::FreeDataChain+15h (00479946)
      00479935 push esi
      40: CPlex* p = this;
      41: while (p != NULL)
      42: {
      43: BYTE* bytes = (BYTE*) p;
      44: CPlex* pNext = p->pNext;
      00479936 mov esi,dword ptr [ecx]
      45: delete[] bytes;
      00479938 push ecx
      00479939 call operator delete (0047f53d)
      0047993E pop ecx
      0047993F test esi,esi
      46: p = pNext;
      00479941 mov ecx,esi
      00479943 jne CPlex::FreeDataChain+5 (00479936)
      00479945 pop esi
      47: }
      48: }

      Regards, Mike

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

      Either the caller provied a bad this (but non-NULL) pointer or the linked list structure is corrupt.

      Steve

      1 Reply Last reply
      0
      • M mla154

        Hello, I'm receiving a windows message box (actual name of EXE omitted):     First-chance exception in ______.exe: 0xC0000005: Access Violation Possible deallocation error?  Any other ideas what the problem may be?  Any help is appreciated.  The disassembly code is shown below (crash at line 44).

        38: void CPlex::FreeDataChain() // free this one and links
        39: {
        00479931 test ecx,ecx
        00479933 je CPlex::FreeDataChain+15h (00479946)
        00479935 push esi
        40: CPlex* p = this;
        41: while (p != NULL)
        42: {
        43: BYTE* bytes = (BYTE*) p;
        44: CPlex* pNext = p->pNext;
        00479936 mov esi,dword ptr [ecx]
        45: delete[] bytes;
        00479938 push ecx
        00479939 call operator delete (0047f53d)
        0047993E pop ecx
        0047993F test esi,esi
        46: p = pNext;
        00479941 mov ecx,esi
        00479943 jne CPlex::FreeDataChain+5 (00479936)
        00479945 pop esi
        47: }
        48: }

        Regards, Mike

        B Offline
        B Offline
        BadKarma
        wrote on last edited by
        #3

        Looking at this piece of code, i got the shivers. :omg: Well it is MFC code so I shouldn't be surprised. Use the call stack to get back to get to your code where the real problem probably occurred. Check for already delete of freed up chunks of memory.

        codito ergo sum

        1 Reply Last reply
        0
        • M mla154

          Hello, I'm receiving a windows message box (actual name of EXE omitted):     First-chance exception in ______.exe: 0xC0000005: Access Violation Possible deallocation error?  Any other ideas what the problem may be?  Any help is appreciated.  The disassembly code is shown below (crash at line 44).

          38: void CPlex::FreeDataChain() // free this one and links
          39: {
          00479931 test ecx,ecx
          00479933 je CPlex::FreeDataChain+15h (00479946)
          00479935 push esi
          40: CPlex* p = this;
          41: while (p != NULL)
          42: {
          43: BYTE* bytes = (BYTE*) p;
          44: CPlex* pNext = p->pNext;
          00479936 mov esi,dword ptr [ecx]
          45: delete[] bytes;
          00479938 push ecx
          00479939 call operator delete (0047f53d)
          0047993E pop ecx
          0047993F test esi,esi
          46: p = pNext;
          00479941 mov ecx,esi
          00479943 jne CPlex::FreeDataChain+5 (00479936)
          00479945 pop esi
          47: }
          48: }

          Regards, Mike

          M Offline
          M Offline
          mla154
          wrote on last edited by
          #4

          The problem has been solved. It turns out that I was allocating an incorrect amount of memory for three variables. To sum up, Old:

          double *var1 = new double[20];

          Changed to:

          double *var1 = new double[correctInt];

          Regards, Mike

          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