Opened 8 months ago

Closed 8 months ago

Last modified 8 months ago

#15951 closed defect (fixed)

Posting too many events causes stack overflow

Reported by: lodle2 Owned by:
Priority: critical Milestone:
Component: wxMSW Version: 3.0.0
Keywords: event stack overflow Cc:
Blocked By: Blocking:
Patch: no

Description

Problem:
If you fill the win32 event queue wx trys to log the fact it cant post any more events which fails due to logging trying to post an event then logs that it cant post and gets into a recursive call leading to a stack overflow.

See diff for a sample which causes the same problem

Expected:
Posted events gets bounced due to full event queue

Attachments (2)

event.diff download (901 bytes) - added by lodle2 8 months ago.
event.2.diff download (874 bytes) - added by lodle2 8 months ago.

Download all attachments as: .zip

Change History (8)

Changed 8 months ago by lodle2

Changed 8 months ago by lodle2

comment:1 Changed 8 months ago by lodle2

event.diff uses wxPostMessage which i got informed wasnt thread safe, second one uses wxQueueMessage but still same result.

comment:2 Changed 8 months ago by lodle2

Call Stack:

wxmsw30ud_vc_desura.dll!wxPrintfConvSpecParser<wchar_t>::wxPrintfConvSpecParser<wchar_t>(const wchar_t * fmt) Line 798 C++

wxmsw30ud_vc_desura.dll!`anonymous namespace'::DoGetArgumentType<wchar_t>(const wchar_t * format, unsigned int n) Line 657 C++
wxmsw30ud_vc_desura.dll!wxFormatString::GetArgumentType(unsigned int n) Line 720 C++
wxmsw30ud_vc_desura.dll!wxArgNormalizer<wchar_t const *>::wxArgNormalizer<wchar_t const *>(const wchar_t * value, const wxFormatString * fmt, unsigned int index) Line 451 C++
wxmsw30ud_vc_desura.dll!wxArgNormalizerWchar<wchar_t const *>::wxArgNormalizerWchar<wchar_t const *>(const wchar_t * value, const wxFormatString * fmt, unsigned int index) Line 469 C++
wxmsw30ud_vc_desura.dll!wxLogger::Log<char const *,int,wchar_t const *,long,wchar_t const *>(const wxFormatString & f1, const char * a1, int a2, const wchar_t * a3, long a4, const wchar_t * a5) Line 973 C++
wxmsw30ud_vc_desura.dll!wxApp::WakeUpIdle() Line 825 C++
wxmsw30ud_vc_desura.dll!wxWakeUpIdle() Line 1021 C++
wxmsw30ud_vc_desura.dll!wxLog::OnLog(unsigned long level, const wxString & msg, const wxLogRecordInfo & info) Line 374 C++
wxmsw30ud_vc_desura.dll!wxLogger::DoCallOnLog(unsigned long level, const wxString & format, char * argptr) Line 1252 C++
wxmsw30ud_vc_desura.dll!wxLogger::DoCallOnLog(const wxString & format, char * argptr) Line 1258 C++
wxmsw30ud_vc_desura.dll!wxLogger::DoLog(const wchar_t * format, ...) Line 1117 C++
wxmsw30ud_vc_desura.dll!wxLogger::Log<char const *,int,wchar_t const *,long,wchar_t const *>(const wxFormatString & f1, const char * a1, int a2, const wchar_t * a3, long a4, const wchar_t * a5) Line 973 C++
wxmsw30ud_vc_desura.dll!wxApp::WakeUpIdle() Line 825 C++
wxmsw30ud_vc_desura.dll!wxWakeUpIdle() Line 1021 C++
wxmsw30ud_vc_desura.dll!wxLog::OnLog(unsigned long level, const wxString & msg, const wxLogRecordInfo & info) Line 374 C++
wxmsw30ud_vc_desura.dll!wxLogger::DoCallOnLog(unsigned long level, const wxString & format, char * argptr) Line 1252 C++
wxmsw30ud_vc_desura.dll!wxLogger::DoCallOnLog(const wxString & format, char * argptr) Line 1258 C++
wxmsw30ud_vc_desura.dll!wxLogger::DoLog(const wchar_t * format, ...) Line 1117 C++
wxmsw30ud_vc_desura.dll!wxLogger::Log<char const *,int,wchar_t const *,long,wchar_t const *>(const wxFormatString & f1, const char * a1, int a2, const wchar_t * a3, long a4, const wchar_t * a5) Line 973 C++
wxmsw30ud_vc_desura.dll!wxApp::WakeUpIdle() Line 825 C++
wxmsw30ud_vc_desura.dll!wxWakeUpIdle() Line 1021 C++
wxmsw30ud_vc_desura.dll!wxLog::OnLog(unsigned long level, const wxString & msg, const wxLogRecordInfo & info) Line 374 C++
wxmsw30ud_vc_desura.dll!wxLogger::DoCallOnLog(unsigned long level, const wxString & format, char * argptr) Line 1252 C++
wxmsw30ud_vc_desura.dll!wxLogger::DoCallOnLog(const wxString & format, char * argptr) Line 1258 C++
wxmsw30ud_vc_desura.dll!wxLogger::DoLog(const wchar_t * format, ...) Line 1117 C++
wxmsw30ud_vc_desura.dll!wxLogger::Log<char const *,int,wchar_t const *,long,wchar_t const *>(const wxFormatString & f1, const char * a1, int a2, const wchar_t * a3, long a4, const wchar_t * a5) Line 973 C++
wxmsw30ud_vc_desura.dll!wxApp::WakeUpIdle() Line 825 C++
wxmsw30ud_vc_desura.dll!wxWakeUpIdle() Line 1021 C++
wxmsw30ud_vc_desura.dll!wxLog::OnLog(unsigned long level, const wxString & msg, const wxLogRecordInfo & info) Line 374 C++
wxmsw30ud_vc_desura.dll!wxLogger::DoCallOnLog(unsigned long level, const wxString & format, char * argptr) Line 1252 C++
wxmsw30ud_vc_desura.dll!wxLogger::DoCallOnLog(const wxString & format, char * argptr) Line 1258 C++
wxmsw30ud_vc_desura.dll!wxLogger::DoLog(const wchar_t * format, ...) Line 1117 C++
wxmsw30ud_vc_desura.dll!wxLogger::Log<char const *,int,wchar_t const *,long,wchar_t const *>(const wxFormatString & f1, const char * a1, int a2, const wchar_t * a3, long a4, const wchar_t * a5) Line 973 C++
wxmsw30ud_vc_desura.dll!wxApp::WakeUpIdle() Line 825 C++
wxmsw30ud_vc_desura.dll!wxWakeUpIdle() Line 1021 C++

comment:3 Changed 8 months ago by vadz

  • Summary changed from Posting to many events causes stack overflow to Posting too many events causes stack overflow

Hmm, r52253 was supposed to fix this but clearly didn't. I have no idea why does PostMessage() fail to be honest, it looks like the queue is full with some other, not WM_NULL messages, but how does this happen exactly?

Anyhow, it looks like we shouldn't try to log an error from here. This does fix the crash, but the program still doesn't work, for any sensible definition of "work", of course, as it keeps (trying to) process(ing) these dummy events and so doesn't do anything else, including responding to the user actions. But this is not something we can fix, the only solution here is to just not do this.

comment:4 Changed 8 months ago by VZ

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

(In [75834]) Don't log error from wxMSW wxWakeUpIdle().

This is not necessary as there is nothing that can be done about this error
anyhow and the function still "works" even if it occurs (it doesn't wake up
anything but it is not necessary to do it if the message queue is already
full) and, worse, results in a crash due to stack overflow.

Closes #15951.

comment:5 Changed 8 months ago by VZ

(In [75835]) Don't log error from wxMSW wxWakeUpIdle().

This is not necessary as there is nothing that can be done about this error
anyhow and the function still "works" even if it occurs (it doesn't wake up
anything but it is not necessary to do it if the message queue is already
full) and, worse, results in a crash due to stack overflow.

Closes #15951.

comment:6 Changed 8 months ago by lodle2

So when is likely to be released? Should i patch 3.0 for now?

Note: See TracTickets for help on using tickets.