Opened 6 years ago

Closed 3 years ago

Last modified 3 years ago

#4489 closed defect (invalid)

segfault on improperly formated wildcard to wxFileDialog

Reported by: dan-sg Owned by: csomor
Priority: normal Milestone:
Component: GUI-all Version:
Keywords: wxFileDialog Cc: dan-sg
Blocked By: Blocking:
Patch: no

Description

This code

wildcard="All files (*.*)|*.*|Python source (*.py)|*.py|"
d=wx.FileDialog(me,message="Openfile...",style=wx.OPEN|wx.MULTIPLE,wildcard=wildcard)
d.ShowModal()

segfaults, once with the error messages below. If I remove the last '|', things work fine

wildcard="All files (*.*)|*.*|Python source (*.py)|*.py"


Python(2120,0xa000cfc0) malloc: * vm_allocate(size=2483056640) failed (error code=3)
Python(2120,0xa000cfc0) malloc:
* error: can't allocate region
Python(2120,0xa000cfc0) malloc: * set a breakpoint in szone_error to debug
Python(2120,0xa000cfc0) malloc:
* vm_allocate(size=2483056640) failed (error code=3)
Python(2120,0xa000cfc0) malloc: * error: can't allocate region
Python(2120,0xa000cfc0) malloc:
* set a breakpoint in szone_error to debug

Change History (6)

comment:1 Changed 6 years ago by dan-sg

oops, forgot my setup:

platform: mac os x 10.4.9
python: 2.5
wxpython: 2.8.3.0

comment:2 Changed 6 years ago by wojdyr

  • Component set to wxMac
  • Keywords wxFileDialog added
  • Owner set to csomor

it doesn't crash on gtk.

Would it be possible to use wxParseCommonDialogsFilter() in MakeUserDataRec() for splitting the wildcard?

comment:3 Changed 3 years ago by Ron Smith

Problem is throughout at least 2.8.4->2.9.1

File: <wx>\src\commmon\filefn.cpp
Method: wxParseCommonDialogsFilter()
Found an ASSERT FAIL in DEBUG mode

Patch (human)
...

wxString description, filter;
int pos = 0;

-- while( pos != wxNOT_FOUND )
++ while( ( pos != wxNOT_FOUND ) && !str.IsEmpty() )

{

pos = str.Find(wxT('|'));

...

comment:4 Changed 3 years ago by csomor

  • Component changed from wxOSX-Carbon to GUI-all

I think it is sufficient when being passed in incorrect wildcard string to give an assert, after all this is not an user error, but a programmer mistake, so running a debug build to discover it seems to be enough for me, or am I overlooking something special with wxPython here ?

comment:5 Changed 3 years ago by vadz

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

I agree that the current behaviour is correct and I'll even add a unit test to ensure that it stays so.

As for the originally reported crash, it must have been fixed since then as I can't reproduce it now.

comment:6 Changed 3 years ago by VZ

(In [67585]) Add a simple unit test for wxParseCommonDialogsFilter().

Verify that this function (which is used for parsing the wildcard strings used
with file-related dialogs) works as expected and also asserts when given
invalid input.

See #4489.

Note: See TracTickets for help on using tickets.