Thread: Can't delete memory

  1. #46
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by jcafaro10 View Post
    Nothing can be accessing the stack after I delete it because I call exit(0) so perhaps it's something else.
    But it IS accessing the stack. The stack contains the return address from when you called delete. That return address is accessed (on the stack you just deleted) when the call to delete returns.

    It's certainly wrong, but I'm not sure it's the cause of your crash.

    At any rate, the "cleanup thread" should probably not be one of your threads, but actually the main program thread, running on the "normal" stack.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  2. #47
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by brewbuck View Post
    But it IS accessing the stack. The stack contains the return address from when you called delete. That return address is accessed (on the stack you just deleted) when the call to delete returns.

    It's certainly wrong, but I'm not sure it's the cause of your crash.

    At any rate, the "cleanup thread" should probably not be one of your threads, but actually the main program thread, running on the "normal" stack.
    Or at the very least, you should not be trying to delete the stack for the cleanup thread until you get back to your main thread.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Assignment Operator, Memory and Scope
    By SevenThunders in forum C++ Programming
    Replies: 47
    Last Post: 03-31-2008, 06:22 AM
  2. Question regarding Memory Leak
    By clegs in forum C++ Programming
    Replies: 29
    Last Post: 12-07-2007, 01:57 AM
  3. linked list recursive function spaghetti
    By ... in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2003, 02:53 PM
  4. Memory handler
    By Dr. Bebop in forum C Programming
    Replies: 7
    Last Post: 09-15-2002, 04:14 PM
  5. multiple indirection...
    By doubleanti in forum C++ Programming
    Replies: 7
    Last Post: 08-31-2001, 10:56 AM