Well, there's definitely something strange going on im wxMSW here.

Problem is the stopping of the search timer in CSearchList::StopGlobalSearch():
inline void CMuleThread::Stop()
{
m_stop = true;
try{
if (IsDetached()) {
Delete();
} else {
Wait();
}
} catch(...) {
m_stop = true;
}
m_stop = true;
}
I have set breakpoints on each
m_stop = true and added a try/catch for good measure. Still what happens is:
- break on first line
- single-step up to the Wait()
- again break on the first line!
Stepping through the whole thing reveals that at some point GetMessage() for the main thread is called (see stack trace) which gets the next timer event, going into CSearchList::OnGlobalSearchTimer() and thus CSearchList::StopGlobalSearch()
again. So the thread is deleted multiply which leads to the crash.
The patch simply deletes the packet first so that OnGlobalSearchTimer() returns immediately without calling StopGlobalSearch() again. Duh.
I'd file a wx bug if I knew how to break this down to a simpler example than whole aMule...