bugLet me illustrate... - Bugs: bug #17757, Segfault with ill-formed xrc file


You are not allowed to post comments on this tracker with your current authentication level.

bug #17757: Segfault with ill-formed xrc file

Submitted by:  Greg Chicares <chicares>
Submitted on:  Fri 15 Sep 2006 02:27:04 PM UTC  
Category: GUISeverity: 2 - Minor
Item Group: wxwindows library defectStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Tue 13 Feb 2018 11:06:33 AM UTC, comment #5:

Testing is deemed to have been completed.

Greg Chicares <chicares>
Project Administrator
Thu 18 Sep 2008 12:17:13 AM UTC, comment #4:

Looks like we've resolved the issue. Comment #3 is discussed here:


Greg Chicares <chicares>
Project Administrator
Sat 02 Aug 2008 04:15:10 PM UTC, comment #3:

The problem was reproducible without my patch (it crashed at exactly the same place) but is also fixed by adding this check.

Thinking more about this, just applying the previously proposed patch is maybe not the best thing to do as adding this check might hide some other problem, what we really need is to not try to update UI at all if the window creation failed anyhow.

So I think the following patch is a better solution:

--- main_wx.cpp 2008-08-02 03:47:24 +0000
+++ main_wx.cpp 2008-08-02 16:13:08 +0000
@@ -156,7 +156,6 @@
EVT_TIMER(wxID_ANY ,Skeleton::UponTimer )
// TODO ?? expunge
// EVT_UPDATE_UI(wxID_ANY ,Skeleton::UponUpdateUI )
- EVT_UPDATE_UI(wxID_SAVE ,Skeleton::UponUpdateFileSave )
// TODO ?? expunge
// Enabling this line prevents the menuitem from performing its required
// action, whether or not the EVT_UPDATE_UI(wxID_SAVE...) handler is also
@@ -692,6 +691,13 @@
return false;

+ // window creation is complete, connect the update UI handlers which
+ // wouldn't work well if the creation had failed (e.g. because we
+ // couldn't load the XRC files)
+ Connect(wxID_SAVE,
+ wxUpdateUIEventHandler(Skeleton::UponUpdateFileSave));

Vadim Zeitlin <zeitlin>
Project Member
Sat 02 Aug 2008 03:32:09 PM UTC, comment #2:

> The file xml_document.xrc doesn't exist any more so I
> can't reproduce this exact problem.

On 20080218T1743Z, its name changed from 'xml_notebook.xrc'
to 'skin.xrc'. (I guess I use the combination of 'ChangeLog'
and cvs as a substitute for svn = "cvs done right".) Is the
problem reproducible with 'skin.xrc'?

Greg Chicares <chicares>
Project Administrator
Sat 02 Aug 2008 01:37:20 PM UTC, comment #1:

The file xml_document.xrc doesn't exist any more so I can't reproduce this exact problem.

I could make LMI crash by making menus.xrc invalid but this is indeed due to a problem in LMI code itself: Skeleton::UponUpdateFileSave() doesn't check that doc_manager_ is non-NULL before using it and it is NULL if the frame creation failed.

After applying this patch:

--- main_wx.cpp 2008-08-02 03:47:24 +0000
+++ main_wx.cpp 2008-08-02 13:33:13 +0000
@@ -1090,6 +1090,9 @@
void Skeleton::UponUpdateFileSave(wxUpdateUIEvent& event)
+ if ( !doc_manager_ )
+ return;
wxDocument* doc = doc_manager_->GetCurrentDocument();
event.Enable(doc && doc->IsModified());

everything works as expected, i.e. an error is shown and the program exits normally. I don't see anything else being wrong right now, please let me know if the problem still can be reproduced in some other way, TIA!

Vadim Zeitlin <zeitlin>
Project Member
Fri 15 Sep 2006 02:27:04 PM UTC, original submission:

If I change 'xml_notebook.xrc' this way:

+ <!-- comment -->
<?xml version="1.0" encoding="ISO-8859-1"?>

(adding a comment on the first line, where none is allowed)
then the program segfaults. I agree that this invalid '.xrc'
file should be rejected, but think a segfault is too extreme.

I'm using a 2006-06-05 snapshot of wxmsw, so it's possible
that this has been corrected in wx-2.7 . Of course, it's also
possible that it's an lmi-specific error, though that would
not be my initial guess.

Steps to reproduce:

Build with the above change.
Run 'lmi_wx_shared.exe' under msw.
Click 'OK' on the messagebox that says
Unable to load xml resources.
[file C:/lmi/src/lmi/main_wx.cpp, line 442]
Click 'Details' on the subsequent messagebox that says
Cannot load resources from file \
Then it crashes. If I click 'OK' instead of 'Details'
on the last messagebox, then it terminates normally.

Here is the beginning of a report from a JIT debugger
(I can post the whole stack trace if that's helpful):

lmi_wx_shared.exe caused an Access Violation at location 101a1269 in module wxmsw270_gcc_342.dll Reading from location 00000000.
Call stack:
AddrPC AddrReturn AddrFrame AddrStack Params
101A1269 0041E2B0 0022F378 0022F360 00000000 FFFFFFFF FFFFFFFF 77D6CC9A
101A1269 wxmsw270_gcc_342.dll:101A1269 _ZNK12wxDocManager18GetCurrentDocumentEv docview.cpp:1404
wxDocument *wxDocManager::GetCurrentDocument() const

> wxView *view = GetCurrentView();

if (view)
return view->GetDocument();

Greg Chicares <chicares>
Project Administrator


No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by chicares (Posted a comment)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 13 Feb 2018 11:06:33 AM UTCchicaresStatusReady For Test=>Fixed
      Assigned towboutin=>None
    Thu 18 Sep 2008 12:17:13 AM UTCchicaresAssigned tozeitlin=>wboutin
    Sat 02 Aug 2008 01:37:20 PM UTCzeitlinStatusNone=>Ready For Test

    Back to the top

    Powered by Savane 3.1-cleanup1