CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2003
    Location
    Japan
    Posts
    2

    Question STL access violation

    Hello !

    I have a problem in my solution which use extensively STL.
    When we remove pointer from list<> in A.dll to B.dll [OK]
    When we put back from B.dll to A.dll [ACCESS VIOLATION]

    We have : prim.dll, env.dll and app.exe (multithread)
    [prim.dll] Shape* newLine();
    [app.exe] list<Shape*> obj;
    [env.dll] list<Shape*> undo;

    The senario :
    [create line] Shape* line=newLine(); obj.push_back(line);
    [delete line] obj.remove(line); undo.push_back(line);
    [undo delete] obj.push_back(undo.front());
    [problem ] obj.front()=0xfeeefeee

    Object was never delete until now, but we got an invalid pointer. Your idea and comments would be very helpful.

    Thanks.

  2. #2
    Join Date
    Dec 2002
    Location
    St.Louis MO, USA
    Posts
    672

    Re: STL access violation

    There is no mistake between the sequence of calling list functions, I think u have to check either each dll returning valid pointer or not before calling push_back into the list.
    Code:
    The senario :
    [create line] Shape* line=newLine();
                        obj.push_back(line);
    [delete line] obj.remove(line);
     undo.push_back(line);
    Shape * pline = NULL;
    pline = undo.front();
    if(pline)
    {
                 [undo delete] obj.push_back(pline);
                 [problem ]      obj.front()=????????
    }
    It May helps u.
    A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.

    NAUMAAN

  3. #3
    Join Date
    Jun 2005
    Posts
    178

    Re: STL access violation

    hi Naumaan,
    Can u explaing ur problem properly..
    i didnt understadn it

    i didnt understand the dll part of it

  4. #4
    Join Date
    Dec 2002
    Location
    St.Louis MO, USA
    Posts
    672

    Re: STL access violation

    Quote Originally Posted by ProElite
    hi Naumaan,
    Can u explaing ur problem properly..
    i didnt understadn it

    i didnt understand the dll part of it
    I have no problem Pro , the OP( Orignal Poster ) is laysovann .
    A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.

    NAUMAAN

  5. #5
    Join Date
    Jun 2005
    Posts
    178

    Re: STL access violation

    OOPs !!!




    ProElite

  6. #6
    Join Date
    Aug 2003
    Location
    Japan
    Posts
    2

    Re: STL access violation

    Hello! Your check is good. But if there is no valid pointer, then the object is gone, and there is noway we can undo. Is there any other way?

  7. #7
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: STL access violation

    [ moved thread ]
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured