Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - GdiPlus Registering Race Condition
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

GdiPlus Registering Race Condition

 Post Reply Post Reply
Author
Message Reverse Sort Order
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Topic: GdiPlus Registering Race Condition
    Posted: 10 September 2018 at 1:23pm
Yes!

It's been my fault...
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
Marco1 View Drop Down
Senior Member
Senior Member


Joined: 16 January 2004
Location: Germany
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote Marco1 Quote  Post ReplyReply Direct Link To This Post Posted: 10 September 2018 at 1:21pm
Was this problem related to your program?
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 05 September 2018 at 6:34am
Fixed it.
Thanks for the help! :)
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 05 September 2018 at 5:27am
Hello,

the easiest way would be to implement a sample that uses multithreading and do something like the following all the time until you get into the race condition:

  CSampleMarkupView* Wnd_ = new CSampleMarkupView(); //Calls CXTPMarkupDrawingContext::Register(TRUE) -> calls CXTPGdiPlus::Register(TRUE)
  // with ASSERT(m_nGdiplusToken == 0 && m_hModule == 0) (XTPGdiPlus.cpp Line 61)
 
  delete Wnd_; //Calls CXTPMarkupDrawingContext::Register(FALSE) -> calls CXTPGdiPlus::Register(FALSE)
  /*
    XTPGdiPlus.cpp Line 75ff:
      m_nCount--;

      if (m_nCount != 0)
      return;
      -----------------> if another thread that wants to call CXTPMarkupDrawingContext::Register(TRUE) interrupts our thread we got an assertion (ASSERT(m_nGdiplusToken == 0 && m_hModule == 0)) in XTPGdiPlus.cpp Line 61

      if (m_hModule)
      {
        // Termination of background thread, which is causing the shutdown problem.
        gdiplusStartupOutput.NotificationUnhook(m_nGdiplusToken);
        GdiplusShutdown(m_nGdiplusToken);
        FreeLibrary(m_hModule);
      }
      m_hModule = NULL;
      m_nGdiplusToken = 0;
   */


using:
class CSampleMarkupView : public CWnd, CXTPMarkupContext {
public:
  CSampleMarkupView() : CWnd(), CXTPMarkupContext() {}
  virtual ~CSampleMarkupView() {}
};

Best regards

Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
agontarenko View Drop Down
Admin Group
Admin Group


Joined: 25 March 2016
Status: Offline
Points: 260
Post Options Post Options   Thanks (0) Thanks(0)   Quote agontarenko Quote  Post ReplyReply Direct Link To This Post Posted: 05 September 2018 at 3:56am
Hello Martin, how I can reproduce it with our samples?

Regards,
Artem Gontarenko
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Posted: 03 September 2018 at 6:07am
Hello,

when creating two different CXTPMarkupContexts both call in their constructor the function CXTPMarkupDrawingContext::Register(TRUE). As this leads to a registering of the CXTPSingleton CXTPGdiPlus 2x sometimes an assertion will be caused, when we got a bad timing.

Can anyone please help me solve this issue by fixing the race condition or telling me if I've used these classes in a wrong way and how to use them correctly?

Thanks for the help in advance.
Martin

Product: Xtreme Toolkit v 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.140 seconds.