CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2012
    Posts
    2

    R6010 error with event

    i'm playing with some proprietary code which is quite in depth so unfortunately i can't post all of it but i think i've covered the main points:

    class FeedHandler
    {

    public:

    FeedHandler() : value_set(false);

    // point of entry to start the feedhandler class
    int run()
    {
    listener->start(); //see processEvent()
    while (!value_set)
    {
    //keep looping
    //Sleep(1000); //will not crash if i Sleep
    }
    listener->stop();
    return 0;
    }

    //callback function to handle events from listener
    virtual bool processEvent()
    {
    value_set = true;
    }

    protected:
    bool value_set;
    }


    listener continually communicates with an external server and triggers an event when a desired value is returned. All I want to do is to keep run() going so listener can keep going until the event is triggered. However, the program sometimes crashes with a R6010 abort() error. Other times it runs fine.
    If I Sleep in the while loop for a minimum of 1s it always runs fine but any less I get the same intermittent error.

    Can someone please explain why I'm getting this error? All the R6010 errors I've googled have been about pointers or strings or accessing memory that's not meant to be.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: R6010 error with event

    And what is this code supposed to do?
    And what is the "listener"?
    Victor Nijegorodov

  3. #3
    Join Date
    Apr 1999
    Posts
    27,449

    Re: R6010 error with event

    Quote Originally Posted by main_brown View Post
    i'm playing with some proprietary code which is quite in depth so unfortunately i can't post all of it but i think i've covered the main points:
    All you posted is a C++ class that has a few functions. There is nothing special or different that makes this little bit of code "odd" or "wrong".
    However, the program sometimes crashes with a R6010 abort() error. Other times it runs fine.
    If I Sleep in the while loop for a minimum of 1s it always runs fine but any less I get the same intermittent error.
    Can someone please explain why I'm getting this error?
    Your program has a memory corruption bug. As to why -- no one knows until someone debugs the program. Heck, many times we don't know what make our own programs we write ourselves fail until we debug the code, so asking us to tell you why your program fails is impossible for us to do. You will need to debug your code.

    More than likely, your program trashes memory due to a threading issue or an issue related to it. Adding Sleep() is not the solution -- it is a clue that the probable cause is a race condition or some other threading issue.
    All the R6010 errors I've googled have been about pointers or strings or accessing memory that's not meant to be.
    The only thing that google will tell you is what that error means. It will not tell you where and exactly the reason that error happens. Continuing to google for those answers will yield you little to no further information. You need to debug the code to find out anything further.

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; July 20th, 2012 at 04:47 PM.

  4. #4
    Join Date
    Jul 2012
    Posts
    2

    Re: R6010 error with event

    Thanks Paul. After reading your reply I did some more debugging and deduced that listener must have been starting a new thread, which when it triggered the callback write to var_set. But at the same time the loop is constantly evaluating var_set as well.

    I've solved it by using intel TBB library and setting mutex locks on var_set.

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