access violation using wxTreeCtrl

51 views
Skip to first unread message

Harry

unread,
Feb 29, 2008, 6:33:09 AM2/29/08
to wx-u...@lists.wxwidgets.org

Hi

In MSW version 2.8.7, using wxTreeCtrl, I get an abort using wxTreeCtrl:
Unhandled exception in treectrl.exe (COMCTL32.DLL): 0xC0000005:
Access Violation.

To duplicate the abort in the sample treectrl, do the following in file
treetest.cpp :
In function MyFrame::CreateTreeWithDefStyle change the first line to
long style = wxTR_DEFAULT_STYLE | wxTR_MULTIPLE | wxTR_HIDE_ROOT |
In function MyTreeCtrl::AddTestItemsToTree comment out the line
SetItemFont(rootId, *wxITALIC_FONT);

Now compile, run, open "Folder child 1", click on the first child, then
exit (via menu or the close button) to get this abort.
Is there anything wrong with using both wxTR_MULTIPLE and wxTR_HIDE_ROOT ?

The stack dump at the moment of the abort is:

[snip]
USER32! 76559924()
wxWindow::MSWDefWindowProc(0x00001101, 0x00000000, 0xffff0000) line 2181
+ 39 bytes
wxTreeCtrl::MSWDefWindowProc(0x00001101, 0x00000000, 0xffff0000) line 2495
wxWindow::MSWWindowProc(0x00001101, 0x00000000, 0xffff0000) line 3378 +
34 bytes
wxTreeCtrl::MSWWindowProc(0x00001101, 0x00000000, 0xffff0000) line 2457
+ 23 bytes
wxWndProc(0x004d0e00, 0x00001101, 0x00000000, 0xffff0000) line 2559 + 28
bytes
USER32! 76571a10()
[snip]
USER32! 7655d93c()
wxTreeCtrl::DeleteAllItems() line 1667 + 29 bytes
wxTreeCtrl::~wxTreeCtrl() line 812
MyTreeCtrl::~MyTreeCtrl() line 68 + 31 bytes
MyTreeCtrl::`scalar deleting destructor'(0x00000001) + 22 bytes
wxWindowBase::DestroyChildren() line 439 + 33 bytes
wxWindow::~wxWindow() line 547
wxPanel::~wxPanel() line 133 + 8 bytes
wxPanel::`scalar deleting destructor'(0x00000001) + 22 bytes
wxWindowBase::DestroyChildren() line 439 + 33 bytes
wxWindow::~wxWindow() line 547
wxTopLevelWindowBase::~wxTopLevelWindowBase() line 75 + 33 bytes
wxTopLevelWindowMSW::~wxTopLevelWindowMSW() line 645 + 15 bytes
wxTopLevelWindow::~wxTopLevelWindow() + 22 bytes
wxFrameBase::~wxFrameBase() line 79 + 29 bytes
wxFrame::~wxFrame() line 214 + 15 bytes
MyFrame::~MyFrame() line 300 + 15 bytes
MyFrame::`scalar deleting destructor'(0x00000001) + 22 bytes
wxAppBase::DeletePendingObjects() line 423 + 33 bytes
wxAppBase::ProcessIdle() line 458
wxEventLoopManual::Run() line 99 + 80 bytes


Vadim Zeitlin

unread,
Feb 29, 2008, 8:14:33 AM2/29/08
to wx-u...@lists.wxwidgets.org
On Fri, 29 Feb 2008 12:33:09 +0100 Harry <"harry dot news at armadillo dot fr"@a.mx.sunsite.dk> wrote:

H> To duplicate the abort in the sample treectrl, do the following in file
H> treetest.cpp :
H> In function MyFrame::CreateTreeWithDefStyle change the first line to
H> long style = wxTR_DEFAULT_STYLE | wxTR_MULTIPLE | wxTR_HIDE_ROOT |
H> In function MyTreeCtrl::AddTestItemsToTree comment out the line
H> SetItemFont(rootId, *wxITALIC_FONT);

This shouldn't be different from using the menu items in the "Style" menu
to toggle the hidden root and selection mode, should it?

H> Now compile, run, open "Folder child 1", click on the first child, then
H> exit (via menu or the close button) to get this abort.
H> Is there anything wrong with using both wxTR_MULTIPLE and wxTR_HIDE_ROOT ?

At least by doing this after the above in the unmodified sample I can't
reproduce the problem. Can you see it in this way?

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/


Harry

unread,
Feb 29, 2008, 11:06:59 AM2/29/08
to wx-u...@lists.wxwidgets.org

Vadim,

Yes, you get the same abort when using the menu items in the "Style"
menu (Toggle hidden root and Toggle selection mode),
but then you also get erroneous asserts and have to answer No to continue.
(These asserts were already the topic of an unanswered previous thread
of mine.)
I suggested modifying the sample source for treectrl in order to get a
cleaner test.

Regards
Harry

Vadim Zeitlin

unread,
Feb 29, 2008, 2:52:02 PM2/29/08
to wx-u...@lists.wxwidgets.org
On Fri, 29 Feb 2008 17:06:59 +0100 Harry <"harry dot news at armadillo dot fr"@a.mx.sunsite.dk> wrote:

H> Yes, you get the same abort when using the menu items in the "Style"
H> menu (Toggle hidden root and Toggle selection mode),
H> but then you also get erroneous asserts and have to answer No to continue.

I do get the asserts but I don't get any problem on exit.

H> (These asserts were already the topic of an unanswered previous thread
H> of mine.)

Ok, I've backported the fixes for the asserts from trunk. I still don't
see any problem on exit in the unmodified sample though.

Vadim Zeitlin

unread,
Mar 3, 2008, 10:31:03 AM3/3/08
to wx-u...@lists.wxwidgets.org
On Mon, 03 Mar 2008 13:56:38 +0100 Harry <"harry dot news at armadillo dot fr"@a.mx.sunsite.dk> wrote:

H> Did you try it with a vanila 2.8.7 version ?

No, sorry, I thought you tried it with 2.8 branch and got the same result
with it. As I'm more interested in fixing it in the latest version and not
confirming that it was present in the old one, could you please test with
2.8 branch from svn? TIA!

H> Did you open "Folder child 1" and click on the first child before exiting ?

Yes, I did.

Harry

unread,
Mar 3, 2008, 7:56:38 AM3/3/08
to wx-u...@lists.wxwidgets.org

Vadim,

I went as far as going back to a vanila 2.8.7 and trying it out with both
Visual Studio 6 and Visual Studio 2005, and I get the abort every time.

Did you try it with a vanila 2.8.7 version ?

Did you open "Folder child 1" and click on the first child before exiting ?

Regards
Harry

Harry

unread,
Mar 5, 2008, 3:39:27 AM3/5/08
to wx-u...@lists.wxwidgets.org

Vadim,

Using Visual Studio 2005 and daily build wxMSW-2008-03-04, I don't get
the assertions,
but I still get the abort:
Unhandled exception at 0x74cdc1f4 in treectrl.exe: 0xC0000005: Access
violation reading location 0xfeeeff0a.
It seems to me like wxTreeCtrl::DeleteAllItems() is trying to delete
already-deleted items.
The difference between your findings and mine might be because of racing
conditions caused by
differences between our respective machines.
If you point me out in the right direction I can continue to debug this
on my machine, or else as we're both
in france we can get in direct contact.

The stack trace is as follows:

comctl32.dll!74cdc1f4()
[snip]
user32.dll!76272d14()
> treectrl.exe!wxWindow::MSWDefWindowProc(unsigned int nMsg=4353,
unsigned int wParam=0, long lParam=-65536) Line 2258 + 0x25 bytes C++
treectrl.exe!wxTreeCtrl::MSWDefWindowProc(unsigned int nMsg=4353,
unsigned int wParam=0, long lParam=-65536) Line 2450 C++
treectrl.exe!wxWindow::MSWWindowProc(unsigned int message=4353,
unsigned int wParam=0, long lParam=-65536) Line 3508 + 0x22 bytes C++
treectrl.exe!wxTreeCtrl::MSWWindowProc(unsigned int nMsg=4353,
unsigned int wParam=0, long lParam=-65536) Line 2412 + 0x17 bytes C++
treectrl.exe!wxWndProc(HWND__ * hWnd=0x000307e2, unsigned int
message=4353, unsigned int wParam=0, long lParam=-65536) Line 2669 +
0x1c bytes C++
user32.dll!76271a10()
[snip]
treectrl.exe!wxTreeCtrl::DeleteAllItems() Line 1630 + 0x1b
bytes C++
treectrl.exe!wxTreeCtrl::~wxTreeCtrl() Line 808 C++
treectrl.exe!MyTreeCtrl::~MyTreeCtrl() Line 68 + 0x18 bytes C++
treectrl.exe!MyTreeCtrl::`scalar deleting destructor'() + 0xf
bytes C++
treectrl.exe!wxWindowBase::DestroyChildren() Line 424 + 0x21
bytes C++
treectrl.exe!wxWindow::~wxWindow() Line 578 C++
treectrl.exe!wxPanel::~wxPanel() Line 133 + 0x1d bytes C++
treectrl.exe!wxPanel::`scalar deleting destructor'() + 0xf
bytes C++
treectrl.exe!wxWindowBase::DestroyChildren() Line 424 + 0x21
bytes C++
treectrl.exe!wxWindow::~wxWindow() Line 578 C++
treectrl.exe!wxTopLevelWindowBase::~wxTopLevelWindowBase() Line
112 + 0x33 bytes C++
treectrl.exe!wxTopLevelWindowMSW::~wxTopLevelWindowMSW() Line 624
+ 0xf bytes C++
treectrl.exe!wxTopLevelWindow::~wxTopLevelWindow() + 0xf bytes C++
treectrl.exe!wxFrameBase::~wxFrameBase() Line 79 + 0x1d bytes C++
treectrl.exe!wxFrame::~wxFrame() Line 214 + 0xf bytes C++
treectrl.exe!MyFrame::~MyFrame() Line 324 + 0xf bytes C++
treectrl.exe!MyFrame::`scalar deleting destructor'() + 0xf
bytes C++
treectrl.exe!wxAppBase::DeletePendingObjects() Line 343 + 0x21
bytes C++
treectrl.exe!wxAppBase::ProcessIdle() Line 376 C++
treectrl.exe!wxEventLoopManual::Run() Line 82 + 0x44 bytes C++
treectrl.exe!wxAppConsoleBase::MainLoop() Line 305 + 0x25 bytes C++
treectrl.exe!wxAppConsoleBase::OnRun() Line 254 C++
treectrl.exe!wxAppBase::OnRun() Line 293 C++
treectrl.exe!wxEntryReal(int & argc=1, wchar_t * *
argv=0x00ffa850) Line 460 + 0x1b bytes C++
treectrl.exe!wxEntry(int & argc=1, wchar_t * * argv=0x00ffa850)
Line 210 + 0xd bytes C++
treectrl.exe!wxEntry(HINSTANCE__ * hInstance=0x00400000,
HINSTANCE__ * __formal=0x00000000, HINSTANCE__ * __formal=0x00000000,
int nCmdShow=1) Line 424 + 0x10 bytes C++
treectrl.exe!WinMain(HINSTANCE__ * hInstance=0x00400000,
HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x002c416a, int
nCmdShow=1) Line 163 + 0x18 bytes C++
treectrl.exe!__tmainCRTStartup() Line 589 + 0x35 bytes C
treectrl.exe!WinMainCRTStartup() Line 414 C

Harry

unread,
Mar 7, 2008, 7:02:28 AM3/7/08
to wx-u...@lists.wxwidgets.org

Vadim, are you still there ?

Regards
Harry

Vadim Zeitlin

unread,
Mar 7, 2008, 3:40:38 PM3/7/08
to wx-u...@lists.wxwidgets.org
On Fri, 07 Mar 2008 13:02:28 +0100 Harry <"harry dot news at armadillo dot fr"@a.mx.sunsite.dk> wrote:

H> Vadim, are you still there ?

Yes. (Un?)fortunately I have some other things to do in the life than
working on wxWidgets. I will test more and answer to your message when I
have more time.

Igor Korot

unread,
Mar 7, 2008, 5:57:34 PM3/7/08
to wx-u...@lists.wxwidgets.org
He is still here. He can't go anywhere. Says so in his signature ;-)

Thank you.

>---------------------------------------------------------------------
>To unsubscribe, e-mail: wx-users-u...@lists.wxwidgets.org
>For additional commands, e-mail: wx-use...@lists.wxwidgets.org
>


Vadim Zeitlin

unread,
Mar 12, 2008, 3:56:22 PM3/12/08
to wx-u...@lists.wxwidgets.org
On Wed, 05 Mar 2008 09:39:27 +0100 Harry <"harry dot news at armadillo dot fr"@a.mx.sunsite.dk> wrote:

H> Using Visual Studio 2005 and daily build wxMSW-2008-03-04, I don't get
H> the assertions,
H> but I still get the abort:
H> Unhandled exception at 0x74cdc1f4 in treectrl.exe: 0xC0000005: Access
H> violation reading location 0xfeeeff0a.

Are you using Vista by chance? There was a discussion on wx-dev recently
about a crash which only happens under this OS (and only in multiselection
mode). The backtrace is not nearly the same though... Please have a look at
http://thread.gmane.org/gmane.comp.lib.wxwidgets.devel/98918 and the patch
referenced there: does applying it help?

H> It seems to me like wxTreeCtrl::DeleteAllItems() is trying to delete
H> already-deleted items.

Hmm, do you have any specific reasons for thinking this? I don't really
see them...

H> The stack trace is as follows:
H>
H> comctl32.dll!74cdc1f4()
H> [snip]
H> user32.dll!76272d14()
H> > treectrl.exe!wxWindow::MSWDefWindowProc(unsigned int nMsg=4353,
H> unsigned int wParam=0, long lParam=-65536) Line 2258 + 0x25 bytes C++
H> treectrl.exe!wxTreeCtrl::MSWDefWindowProc(unsigned int nMsg=4353,
H> unsigned int wParam=0, long lParam=-65536) Line 2450 C++
H> treectrl.exe!wxWindow::MSWWindowProc(unsigned int message=4353,
H> unsigned int wParam=0, long lParam=-65536) Line 3508 + 0x22 bytes C++
H> treectrl.exe!wxTreeCtrl::MSWWindowProc(unsigned int nMsg=4353,
H> unsigned int wParam=0, long lParam=-65536) Line 2412 + 0x17 bytes C++
H> treectrl.exe!wxWndProc(HWND__ * hWnd=0x000307e2, unsigned int
H> message=4353, unsigned int wParam=0, long lParam=-65536) Line 2669 +
H> 0x1c bytes C++
H> user32.dll!76271a10()
H> [snip]
H> treectrl.exe!wxTreeCtrl::DeleteAllItems() Line 1630 + 0x1b
H> bytes C++
H> treectrl.exe!wxTreeCtrl::~wxTreeCtrl() Line 808 C++

DeleteAllItems() is called and it sends TVM_DELETEITEM to the control
(this is the message 4353) and I don't understand why would the items be
already deleted.

BTW, in the 2nd post in the above thread I wrote about how to get symbols
for the frames in user32.dll and comctl32.dll, please see the first
paragraph of http://article.gmane.org/gmane.comp.lib.wxwidgets.devel/98926
Could you please set your _NT_SYMBOL_PATH and show the backtrace with the
symbols? This might give some more information as right now I really don't
have any idea about what to do with this.

Thanks!

Harry

unread,
Mar 17, 2008, 6:42:06 AM3/17/08
to wx-u...@lists.wxwidgets.org

Vadim,

Yes, I'm using Vista.
Curiously, the abort happens in TV_SetItemState() as it does for the
patch you referred to,
although the circumstances look different (I'm closing the window).
Where can I get this patch ? Or do I simply download the last daily build ?

For what it may help, here's my stack trace with symbols (using
wxMSW-2008-03-04):

comctl32.dll!TV_SetItemState() + 0xd bytes
comctl32.dll!TV_SelectItem() + 0x5bb6c bytes
comctl32.dll!TV_DeleteItemRecurse() - 0x6a5e bytes
comctl32.dll!TV_DeleteItemRecurse() + 0x439 bytes
comctl32.dll!TV_DeleteItem() + 0x67 bytes
comctl32.dll!TV_WndProc() + 0x44e8e bytes
user32.dll!_InternalCallWinProc@20() + 0x23 bytes
user32.dll!_UserCallWinProcCheckWow@32() + 0xb3 bytes
user32.dll!_CallWindowProcAorW@24() + 0x51 bytes
user32.dll!_CallWindowProcW@20() + 0x1b bytes
> treectrl.exe!wxWindow::MSWDefWindowProc(unsigned int nMsg=4353,

unsigned int wParam=0, long lParam=-65536) Line 2258 + 0x25 bytes C++

treectrl.exe!wxTreeCtrl::MSWDefWindowProc(unsigned int nMsg=4353,

unsigned int wParam=0, long lParam=-65536) Line 2450 C++

treectrl.exe!wxWindow::MSWWindowProc(unsigned int message=4353,

unsigned int wParam=0, long lParam=-65536) Line 3508 + 0x22 bytes C++

treectrl.exe!wxTreeCtrl::MSWWindowProc(unsigned int nMsg=4353,

unsigned int wParam=0, long lParam=-65536) Line 2412 + 0x17 bytes C++

treectrl.exe!wxWndProc(HWND__ * hWnd=0x00050f58, unsigned int

message=4353, unsigned int wParam=0, long lParam=-65536) Line 2669 +

0x1c bytes C++
user32.dll!_InternalCallWinProc@20() + 0x23 bytes
user32.dll!_UserCallWinProcCheckWow@32() + 0xb3 bytes
user32.dll!_SendMessageWorker@20() + 0xd5 bytes
user32.dll!_SendMessageW@16() + 0x49 bytes

treectrl.exe!wxTreeCtrl::DeleteAllItems() Line 1630 + 0x1b

bytes C++


treectrl.exe!wxTreeCtrl::~wxTreeCtrl() Line 808 C++

argv=0x012aa908) Line 460 + 0x1b bytes C++
treectrl.exe!wxEntry(int & argc=1, wchar_t * * argv=0x012aa908)

Line 210 + 0xd bytes C++
treectrl.exe!wxEntry(HINSTANCE__ * hInstance=0x00400000,
HINSTANCE__ * __formal=0x00000000, HINSTANCE__ * __formal=0x00000000,
int nCmdShow=1) Line 424 + 0x10 bytes C++
treectrl.exe!WinMain(HINSTANCE__ * hInstance=0x00400000,

HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00304272, int

nCmdShow=1) Line 163 + 0x18 bytes C++
treectrl.exe!__tmainCRTStartup() Line 589 + 0x35 bytes C
treectrl.exe!WinMainCRTStartup() Line 414 C

kernel32.dll!@BaseThreadInitThunk@12() + 0x12 bytes
ntdll.dll!__RtlUserThreadStart@8() + 0x27 bytes

Harry

unread,
Mar 17, 2008, 6:53:17 AM3/17/08
to wx-u...@lists.wxwidgets.org

The last stack trace got a bit garbled on end of lines, so here it is again:

Vadim Zeitlin

unread,
Mar 17, 2008, 9:28:34 AM3/17/08
to wx-u...@lists.wxwidgets.org
On Mon, 17 Mar 2008 11:42:06 +0100 Harry <"harry dot news at armadillo dot fr"@a.mx.sunsite.dk> wrote:

H> Yes, I'm using Vista.

Ok, then it's probably indeed the same bug. Please try applying the patch
http://sf.net/tracker/index.php?func=detail&aid=1911805&group_id=9863&atid=309863
and let us know if it helps.

Thanks,

Harry

unread,
Mar 17, 2008, 11:15:08 AM3/17/08
to wx-u...@lists.wxwidgets.org

Yes, it's the same bug - the abort has disappeared.

Thanks (et A+)
Harry

Reply all
Reply to author
Forward
0 new messages