Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Skin Framework
  New Posts New Posts RSS Feed - m_arrDescriptors asserts/crashes
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

m_arrDescriptors asserts/crashes

 Post Reply Post Reply
Author
Message
artsd View Drop Down
Groupie
Groupie


Joined: 07 January 2007
Location: United States
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote artsd Quote  Post ReplyReply Direct Link To This Post Topic: m_arrDescriptors asserts/crashes
    Posted: 15 January 2007 at 1:15pm
I am experiencing intermittent skin related crashes with my multi-threaded app at both startup and when changing skins at runtime. BTW, this app uses the ribbon.
 
In my app CXTPFrameWnd derived class' ctor, I call:
 
    XTPSkinManager()->SetApplyOptions(xtpSkinApplyMetrics |
      xtpSkinApplyFrame | xtpSkinApplyColors);
 
    XTPSkinManager()->LoadSkin(m_strMediaPath + strSkinFile, strSkinIni);

When the user changes the skin at runtime, I just call the LoadSkin() line.
 
After the mainframe has been created and after OnCreateClient() is done it's work I create 3 worker threads that each create a modeless dialog box. This is where the problem comes in.
 
At program startup (in the debugger) I sometimes get crashes relating to the m_arrDescriptors in the CXTPSkinObject. Most of the time it does not crash at startup. But then I can make it crash by changing the skin 5 or 10 times.
 
Do I need to do something special with the mutlithreaded aspect of this?
 
Seems like access to m_arrDescriptors may not be thread safe or something. Perhaps one of my worker threads is accessing the m_arrDescriptors while the main thread is modifying it through the LoadSkin() call?!?
 
The program does not have this problem if I don't create the 3 worker threads. These threads are just simple CWinThread objects that create a modeless CDialog.
 
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 15 January 2007 at 1:44pm
Hi,
It will be very helpfull if you attach some sample showing it.
Do you use 10.4 release?
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
artsd View Drop Down
Groupie
Groupie


Joined: 07 January 2007
Location: United States
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote artsd Quote  Post ReplyReply Direct Link To This Post Posted: 15 January 2007 at 3:35pm
OK. I made a version of RibbonSample_vc60 that will crash but not in quite
in the same way. I compiled with VC6 SP3.
 
 
This sample starts 4 threads that each own a modeless CDialog (in this sample, these threads leak but that is ok).
 
All 4 modeless diaogs are on top of each other so move them so you see all of them.
 
On the ribbon, use the "Skin Test" group to rapidly change between the various skins (click between them quickly). You will get the crash within 20 clicks. Also, notice that the 10 progress bars on each of the modeless dialog bars are not painting correctly if using a skin (paint fine if no skin).
 
Stack dump:
 
memcpy(unsigned char * 0xfeeefeee, unsigned char * 0x01cbd909, unsigned long 57) line 242
png_combine_row(png_struct_def * 0x01cbd4d8, unsigned char * 0xfeeefeee, int 255) line 2258 + 114 bytes
png_read_row(png_struct_def * 0x01cbd4d8, unsigned char * 0xfeeefeee, unsigned char * 0x00000000) line 778 + 18 bytes
png_read_image(png_struct_def * 0x01cbd4d8, unsigned char * * 0x01cbdd90) line 890 + 17 bytes
PngLoadImage(CFile * 0x0298f398 {pos=350 size=366}, unsigned char * * 0x0298f334, unsigned long * 0x0298f330, unsigned long * 0x0298f32c, int * 0x0298f328, png_color_struct * 0x00000000) line 201 + 16 bytes
CXTPGraphicBitmapPng::LoadFromFile(CFile * 0x0298f398 {pos=350 size=366}) line 341 + 29 bytes
CXTPGraphicBitmapPng::LoadFromResource(HINSTANCE__ * 0x10000000, HRSRC__ * 0x100024f0) line 325 + 12 bytes
CXTPImageManagerIcon::LoadBitmapFromResource(HINSTANCE__ * 0x10000000, const char * 0x01cbcf5c, int * 0x0298f578) line 741 + 16 bytes
XTPSkinFrameworkLoadBitmap(HINSTANCE__ * 0x10000000, const char * 0x01cbcf5c, int & 0) line 442 + 17 bytes
CXTPSkinImage::LoadFile(HINSTANCE__ * 0x10000000, const char * 0x01cbcf5c) line 206 + 17 bytes
CXTPSkinManagerResourceFile::LoadImageA(CString {"BLUE_PROGRESSTRACK_BMP"}) line 211 + 26 bytes
CXTPSkinImages::LoadFile(CXTPSkinManagerResourceFile * 0x003360f8, const char * 0x01cbcef4) line 515 + 29 bytes
CXTPSkinManagerSchemaDefault::DrawThemeBackground(CDC * 0x0298f984 {hDC=??? attrib=???}, CXTPSkinManagerClass * 0x01cba2d0, int 1, int 0, const tagRECT * 0x0298f9b4 {top=0 bottom=23 left=0 right=258}) line 754 + 36 bytes
CXTPSkinManagerClass::DrawThemeBackground(CDC * 0x0298f984 {hDC=??? attrib=???}, int 1, int 0, const tagRECT * 0x0298f9b4 {top=0 bottom=23 left=0 right=258}) line 792 + 47 bytes
CXTPSkinObjectProgress::OnPaint() line 119
CWnd::OnWndMsg(unsigned int 15, unsigned int 0, long 0, long * 0x0298fc8c) line 1825
CXTPSkinObject::OnHookMessage(unsigned int 15, unsigned int & 0, long & 0, long & 0) line 278 + 36 bytes
CXTPSkinObjectFrame::OnHookMessage(unsigned int 15, unsigned int & 0, long & 0, long & 0) line 850
CXTPSkinManager::HookWndProc(HWND__ * 0x00370c22, unsigned int 15, unsigned int 0, long 0) line 576 + 32 bytes
USER32! 77d48734()
USER32! 77d48816()
USER32! 77d4b4c0()
USER32! 77d4b50c()
NTDLL! 7c90eae3()
USER32! 77d496c7()
CWinThread::PumpMessage() line 846
CWinThread::Run() line 480 + 11 bytes
_AfxThreadEntry(void * 0x0012eb50) line 125 + 11 bytes
_threadstartex(void * 0x01d25f20) line 212 + 13 bytes
CXTPSkinManagerApiHook::ThreadProcHook(void * 0x01d71d58) line 775 + 9 bytes
KERNEL32! 7c80b683()
 
Back to Top
artsd View Drop Down
Groupie
Groupie


Joined: 07 January 2007
Location: United States
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote artsd Quote  Post ReplyReply Direct Link To This Post Posted: 16 January 2007 at 9:48am
Bump.  Oleg, did you get a chance to try my test program?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 16 January 2007 at 10:12am

Hello,

 
I can't. Think because this change we made right after release:
Source\GraphicLibrary\XTPGraphicBitmapPng.cpp
 
 static png_byte   **ppbRowPointers = NULL;
==================
 png_byte          **ppbRowPointers = NULL;
 
 
please replace this line, rebuild library and check if you still see crush.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
artsd View Drop Down
Groupie
Groupie


Joined: 07 January 2007
Location: United States
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote artsd Quote  Post ReplyReply Direct Link To This Post Posted: 17 January 2007 at 9:47am
I applied your fix and it seemed to help but I think their are more thread problems.
 
I modified the Ribbon sample again. This time the 4 threaded windows will update the progress bars inside them every 100 milliseconds.
 
The progress bars are not painting correctly (half painted). Sometimes, one of the dialogs does not get its title bar / top of frame painted.
 
Changing skins while running also causes problems. I have gotten it to crash in CXTPSkinObjectFrame::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp) and in CXTPSkinManagerClass::DrawThemeBackground(CDC* pDC, int iPartId, int iStateId, const RECT *pRect).
 
 
 
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 17 January 2007 at 10:28am
Hi, yes thank you. Seems appears than same bitmaps drawn in same time. if you run only 1 thread it will work. We will check it how it can be improved.
 
May be you can disable skinning for work threads now?
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
artsd View Drop Down
Groupie
Groupie


Joined: 07 January 2007
Location: United States
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote artsd Quote  Post ReplyReply Direct Link To This Post Posted: 17 January 2007 at 10:32am
Thanks for looking into this.
 
I disabled the threads use of skinning by calling this before the threads are created and it works:
 
XTPSkinManager()->SetAutoApplyNewThreads(FALSE);
I have 2 other modeless dialogs (owned by my main thread) that I would also like to disable skinning (to match the modeless dialogs that have the thread problem).  But all other windows owned by main thread I would like to continue to thread.
 
How do i disable threading for a specific window?
Back to Top
artsd View Drop Down
Groupie
Groupie


Joined: 07 January 2007
Location: United States
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote artsd Quote  Post ReplyReply Direct Link To This Post Posted: 17 January 2007 at 10:36am

BTW, with only one thread running, the progress bars do paint correctly, but i still get crashes in CXTPSkinObjectFrame::OnNcCalcSize() and CXTPSkinManagerClass::DrawThemeBackground() when changing skins (it may take a few skin changes to make it happen)

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.156 seconds.