Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

wx-2.8.7 Logging in Multi-Threaded environment

2 views
Skip to first unread message

JC Francois

unread,
Feb 24, 2008, 6:48:07 AM2/24/08
to
Hi,

I am writing an application with the main thread handling the GUI and multiple threads each reading files and writing to a SQLite database. in Debug mode all threads write to the debugging facility, a log file set using wxLog::SetActiveTarget) and a wxLogWindow Window to intercept and display messages on the screen.

Everything is working fine except that from time to time the app crashes unexpectedly. I captured the call stack and it seems to point towards a issue with logging to the wxTextCtrl of the wxLogWindow:

#0 000E5172    ??() (??:??)
#1 66EC7EAB    wxTextCtrl::GetLastPosition(this=0xe41588) (../../src/msw/textctrl.cpp:1329)
#2 66F8E08A    wxLogWindow::DoLogString(this=0xe40c78, szString=0xee6cb4) (../../src/generic/logg.cpp:654)
#3 66D9562E    wxLog::DoLog(this=0xe40c78, level=3, szString=0xee6cb4, t=1203852231) (../../src/common/log.cpp:476)
#4 66F8E015    wxLogWindow::DoLog(this=0xe40c78, level=3, szString=0xee6cb4, t=1203852231) (../../src/generic/logg.cpp:642)
#5 66D95000    wxLog::OnLog(level=3, szString=0xee6cb4, t=1203852231) (../../src/common/log.cpp:350)
#6 66D93F33    wxVLogMessage(szFormat=0x42725c, argptr=0x150fc2c ", Æ\001") (../../src/common/log.cpp:121)
#7 66D93FA4    wxLogMessage(szFormat=0x42725c) (../../src/common/log.cpp:121)
#8 004094E6    jcFeedProcessor::Read(this=0x150fe18, XmlUrl=@0x150fe18) (C:/dev/funnel/feed/feed.cpp:116)
#9 00408F28    jcFeedProcessor::Read(this=0x150fe18) (C:/dev/funnel/feed/feed.cpp:48)
#10 00406BC3    jcDatabase::LoadFeed(this=0x2155420, XmlUrl=@0x1c5beec) (C:/dev/funnel/database.cpp:569)
#11 004128A2    jcFeedThread::Entry(this=0x1c5bec0) (C:/dev/funnel/thread.cpp:36)
#12 66DF0E68    wxThreadInternal::DoThreadStart(thread=0x1c5bec0) (../../src/msw/thread.cpp:530)
#13 66DF0F82    wxThreadInternal::WinThreadStart(param=0x1c5bec0) (../../src/msw/thread.cpp:557)
#14 77C3A3B0    msvcrt!_endthreadex() (C:\WINDOWS\system32\msvcrt.dll:??)
#15 01C5BEC0    ??() (??:??)
#16 00000000    ??() (??:??)


wxMSW-2.8.7 unicode MinGW with gcc-3.4.5

My questions are: in a  multi-threaded environment do wxLogDebug calls need to be protected by a Mutex? Would logging to file only (i.e. no log window) resolve the issue?


Thanks,

 ~jc

Vadim Zeitlin

unread,
Feb 24, 2008, 10:18:58 AM2/24/08
to
On Sun, 24 Feb 2008 12:48:07 +0100 JC Francois <jc.fr...@gmail.com> wrote:

JF> My questions are: in a multi-threaded environment do wxLogDebug calls
JF> need to be protected by a Mutex?

When the log target is not thread safe (as is the case of wxLogWindow),
yes.

JF> Would logging to file only (i.e. no log window) resolve the issue?

I think so. If it doesn't, this would definitely be a bug.

Regards,
VZ

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


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

jc.fr...@gmail.com

unread,
Feb 25, 2008, 7:33:03 AM2/25/08
to
Thanks Vadim.

You are correct. I removed the logging window and the crashes seem to be gone.

I am now sending messages only to the log file and I monitor it using 'tail -f'. This actually works really well.

Thanks!

~jc
0 new messages