Closed wxtrac closed 13 years ago
The program has a background wxThread that downloads images off a web site. The images are stored locally, and then an wxEvent is posted to the main thread to handle the images. The code mostly works, but sometimes crashes while downloading.
Sorry, there is no chance whatsoever we can do anything about it without a reproducible, simple test case.
I'd add that you should test your code with 2.9.1, a lot of things have changed in the socket code there so it might magically start to work there. Or maybe die with a more clear error.
I tried out the changes from #8904 and so far so good. I was never able to consistently reproduce this bug, but it kept happening about 1 out of 50 times I run the app. I have implemented the patch and have had any crashes for a day now. No other strange behavior, everything seems to work just fine.
Herewith the patch:
diff -up wxMac-2.8.11/src/unix/gsocket.cpp.tomtom wxMac-2.8.11/src/unix/gsocket.cpp --- wxMac-2.8.11/src/unix/gsocket.cpp.tomtom 2011-02-13 17:40:10.000000000 +0200 +++ wxMac-2.8.11/src/unix/gsocket.cpp 2011-02-13 17:57:48.000000000 +0200 @@ -1543,6 +1543,14 @@ GSocketError GSocket::Input_Timeout()
if (!m_non_blocking) { +
wxFD_ZERO(&readfds); wxFD_SET(m_fd, &readfds); ret = select(m_fd + 1, &readfds, NULL, NULL, &tv);
I didn't realize this was the same as #8904, thanks for finding it.
FWIW it would still be interesting to know if you see any problems with 2.9/current svn.
(In [66976]) Work around an intermittent crash in GSocket under Mac.
The socket descriptor may somehow be invalid when an input timeout notification is received.
This is almost certainly not the right fix but the code has completely changed in 2.9 so it doesn't make much sense to spend time on fixing it properly here. But adding this check seems to be enough to fix the crash, see #12264.
Closes #8904.
Issue migrated from trac ticket # 12264
component: wxOSX (any toolkit) | priority: normal | resolution: duplicate | keywords: repro-needed
2010-07-23 15:05:11: johan.vdberg (Johan van den Berg) created the issue
The following crash happens every now and again (i believe when http read takes too long).
Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0xd023f990 0x00167fa8 in GSocket::Input_Timeout (this=0x1750c038) at ../src/unix/gsocket.cpp:1547 1547 wxFD_SET(m_fd, &readfds);
(gdb) bt full
0 0x00167fa8 in GSocket::Input_Timeout (this=0x1750c038) at ../src/unix/gsocket.cpp:1547
tv_sec = 600, tv_usec = 0 } readfds = { fds_bits = {0 <repeats 32 times>} } ret = 47
1 0x0016978f in GSocket::Read (this=0x1750c038, buffer=0xb0240b03 "", size=181) at ../src/unix/gsocket.cpp:1164
2 0x00163642 in wxSocketBase::_Read (this=0x1750c418, buffer=0xb0240b03, nbytes=181) at ../src/common/socket.cpp:363
3 0x00163a8e in wxSocketBase::Read (this=0x1750c418, buffer=0xb023fbb8, nbytes=4096) at ../src/common/socket.cpp:308
No locals.
4 0x001621f4 in wxSocketInputStream::OnSysRead (this=0x1750ca38, buffer=0xb023fbb8, size=4096) at ../src/common/sckstrm.cpp:90
5 0x0015f7ec in wxHTTPStream::OnSysRead (this=0x1750ca38, buffer=0xb023fbb8, bufsize=4096) at ../src/common/http.cpp:362
6 0x001c51e2 in wxInputStream::Read (this=0x1750ca38, buf=0xb023fbb8, size=4096) at ../src/common/stream.cpp:846
7 0x001c34f8 in wxInputStream::Read (this=0x1750ca38, stream_out=@0xb0240c64) at ../src/common/stream.cpp:877
8 0x0015a567 in wxInternetFSHandler::OpenFile (this=0x15a50348, location=@0xb0240cfc) at ../src/common/fs_inet.cpp:118