Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#11927 closed defect (fixed)

Regression - wxMimeTypesManager causes segmentation fault.

Reported by: hguemar Owned by:
Priority: normal Milestone:
Component: base Version: 2.8.10
Keywords: Cc: dan@…
Blocked By: Blocking:
Patch: no


Description of problem:
regression in wxWidgets 2.8, calling GetFileTypeFromExtension method on
wxMimeTypesManager cause a segfault

Version-Release number of selected component (if applicable):
2.8 (works fine with 2.6)

How reproducible:
python -c "import wx; wx.TheMimeTypesManager.GetFileTypeFromExtension('pdf')"
I attached a minimalistic sample in C++

Steps to Reproduce:

  1. call GetFileTypeFromExtension on wxMimeTypesManager object
  2. segfault


Actual results:
segmentation fault

Expected results:
return a wxFileType object or null pointer

Additional info:
I am able to reproduce this on fedora 12 and debian with wxGTK 2.8 (works fine with 2.6)

Attachments (1) download (352 bytes) - added by hguemar 8 years ago.
minimalistic c++ test case

Download all attachments as: .zip

Change History (5)

Changed 8 years ago by hguemar

minimalistic c++ test case

comment:1 Changed 8 years ago by sharkcz

  • Cc dan@… added

The issue is present also in svn trunk. The output from gdb is

(gdb) run
Starting program: /tmp/crappy 
[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
wxAppConsoleBase::GetTraits (this=0x0) at src/common/appbase.cpp:293
293	    if ( !m_traits )
Missing separate debuginfos, use: debuginfo-install SDL-1.2.13-11.fc12.x86_64 libXxf86vm-1.1.0-1.fc12.x86_64 libmspack-0.0-0.7.20060920alpha.fc12.x86_64
(gdb) where
#0  wxAppConsoleBase::GetTraits (this=0x0) at src/common/appbase.cpp:293
#1  0x00007ffff64fd5e6 in wxMimeTypesManagerImpl::InitIfNeeded (this=0x635580) at src/unix/mimetype.cpp:510
#2  0x00007ffff64fe0dd in wxMimeTypesManagerImpl::GetFileTypeFromExtension (this=0x635580, ext=...) at src/unix/mimetype.cpp:832
#3  0x00007ffff643c55d in wxMimeTypesManager::GetFileTypeFromExtension (this=0x7ffff67ae880, ext=...) at src/common/mimecmn.cpp:625
#4  0x0000000000400e7b in main () at
(gdb) l
288	}
290	wxAppTraits *wxAppConsoleBase::GetTraits()
291	{
292	    // FIXME-MT: protect this with a CS?
293	    if ( !m_traits )
294	    {
295	        m_traits = CreateTraits();
297	        wxASSERT_MSG( m_traits, wxT("wxApp::CreateTraits() failed?") );

comment:2 Changed 8 years ago by vadz

  • Status changed from new to confirmed

In general, it's not a good idea to use any parts of wxWidgets before initializing it. But if this worked before it's arguably a good idea to avoid crashing now so I'll fix this, thanks for reporting (and separate thanks for the stack trace, this was useful).

comment:3 Changed 8 years ago by VZ

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

(In [63935]) Don't crash if wxMimeTypesManager is used before wxApp creation.

This is arguably not a supported use case but this apparently used to work
before and so it's probably not a good idea to break it now.

Closes #11927.

comment:4 Changed 8 years ago by VZ

(In [63936]) Fix crash in wxMimeTypesManager [backport of r63935 from trunk].

Don't crash if wxMimeTypesManager is used before wxApp creation.

See #11927.

Note: See TracTickets for help on using tickets.