Ticket #14769 (closed defect: fixed)

Opened 8 months ago

Last modified 8 months ago

[MSW] Crash in wxGDIPlusRendererModule

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

Description

To reproduce:
- start unmodified "drawing" sample
- file menu -> Graphics screen
- close application

Crashes when deleting the new 'gs_drawTextStringFormat'.

Attachments

gdi32-DeleteStringFormat-callstack.txt download (3.9 KB) - added by markusj 8 months ago.

Change History

Changed 8 months ago by vadz

  • status changed from new to closed
  • resolution set to worksforme

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 8 months ago by markusj

Changed 8 months 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.

Changed 8 months ago by vadz

  • status changed from closed to reopened
  • resolution deleted
  • milestone set to 2.9.5

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  
    22832283class wxGDIPlusRendererModule : public wxModule 
    22842284{ 
    22852285public: 
     2286    wxGDIPlusRendererModule() 
     2287    { 
     2288        // We must be uninitialized before GDI+ DLL itself is unloaded. 
     2289        AddDependency("wxGdiPlusModule"); 
     2290    } 
     2291 
    22862292    virtual bool OnInit() { return true; } 
    22872293    virtual void OnExit() 
    22882294    { 

Does it?

Changed 8 months ago by markusj

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

Changed 8 months ago by markusj

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

Changed 8 months 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.

Changed 8 months ago by VZ

  • status changed from reopened to closed
  • resolution set to fixed

(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.