Opened 5 years ago

Closed 5 years ago

#14769 closed defect (fixed)

[MSW] Crash in wxGDIPlusRendererModule

Reported by: markusj Owned by:
Priority: normal Milestone: 2.9.5
Component: wxMSW Version: stable-latest
Keywords: Cc:
Blocked By: Blocking:
Patch: no


To reproduce:

  • start unmodified "drawing" sample
  • file menu -> Graphics screen
  • close application

Crashes when deleting the new 'gs_drawTextStringFormat'.

Attachments (1)

gdi32-DeleteStringFormat-callstack.txt download (3.9 KB) - added by markusj 5 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 5 years ago by vadz

  • Resolution set to worksforme
  • Status changed from new to closed

Sorry, I don't see this. Please try rebuilding all and testing again. If it still happens, could you please provide a full stack trace? What is the value of gs_drawTextStringFormat when it's being deleted?

Changed 5 years ago by markusj

comment:2 Changed 5 years ago by markusj

Did a full rebuild, still happens. But only under XP, not Windows 7.

I don't know if it's relevant, but i noticed that the module "wxGdiPlusModule" is destroyed first, this one unloads GDI32.DLL. The crash then happens later when "wxGDIPlusRendererModule" is destroyed.

Callstack attached.

comment:3 Changed 5 years ago by vadz

  • Milestone set to 2.9.5
  • Resolution worksforme deleted
  • Status changed from closed to reopened

Thanks for your remark, I do think it's relevant and I believe the following patch should fix the problem:

  • src/msw/graphics.cpp

    diff --git a/src/msw/graphics.cpp b/src/msw/graphics.cpp
    index f447d15..8f1844b 100644
    a b wxGraphicsBitmap wxGDIPlusRenderer::CreateSubBitmap( const wxGraphicsBitmap &bit 
    22832283class wxGDIPlusRendererModule : public wxModule
     2286    wxGDIPlusRendererModule()
     2287    {
     2288        // We must be uninitialized before GDI+ DLL itself is unloaded.
     2289        AddDependency("wxGdiPlusModule");
     2290    }
    22862292    virtual bool OnInit() { return true; }
    22872293    virtual void OnExit()
    22882294    {

Does it?

comment:4 Changed 5 years ago by markusj

Yes, perfect. Thanks for the fast response, much appreciated.

comment:5 Changed 5 years ago by markusj

Just out of curiosity: Do you have an explanation why this didn't crash under Windows 7?

comment:6 Changed 5 years ago by vadz

The module (un)loading order may have been different or, more likely, something else holds on GDI+ DLL under Windows 7 so it wasn't really unloaded when we did it.

comment:7 Changed 5 years ago by VZ

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [72717]) Ensure the correct cleanup order for GDI+-related modules in wxMSW.

GDI+ DLL could be unloaded by wxGdiPlusModule before wxGDIPlusRendererModule::
OnExit() was called, resulting in a crash when trying to call a GDI+ function
from the latter.

Fix this by adding a correct dependency between the modules.

Closes #14769.

Note: See TracTickets for help on using tickets.