wxWidgets / wxWidgets

Cross-Platform C++ GUI Library
https://www.wxwidgets.org/
6.09k stars 1.76k forks source link

Intermittend EXC_BAD_ACCESS in GSocket::Input_Timeout at ../src/unix/gsocket.cpp:1547 #12264

Closed wxtrac closed 13 years ago

wxtrac commented 14 years ago

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 = {

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

ret = 47

2 0x00163642 in wxSocketBase::_Read (this=0x1750c418, buffer=0xb0240b03, nbytes=181) at ../src/common/socket.cpp:363

more = true
total = 3915
ret = 47

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

ret = 4096

5 0x0015f7ec in wxHTTPStream::OnSysRead (this=0x1750ca38, buffer=0xb023fbb8, bufsize=4096) at ../src/common/http.cpp:362

ret = 1855742

6 0x001c51e2 in wxInputStream::Read (this=0x1750ca38, buf=0xb023fbb8, size=4096) at ../src/common/stream.cpp:846

p = 0xb023fbb8 "jX????6??\f?4\003W~ر?\022??v?\b??d\\u??yGO?'NCδ??CL??g?A\027?[\021?\bJ??MI?\016i"
read = 0
__FUNCTION__ = "Read"

7 0x001c34f8 in wxInputStream::Read (this=0x1750ca38, stream_out=@0xb0240c64) at ../src/common/stream.cpp:877

bytes_read = 4096
lastcount = 8192
buf = "jX????6??\f?4\003W~ر?\022??v?\b??d\\u??yGO?'NCδ??CL??g?A\027?[\021?\bJ??MI?\016i\000 \035Rj?o\016??=?\000k?U*\001?ι?S5\b?S??U+?$\\!?yȒ%??XZ\rC?Ɛ?2?\002\022?\0023PM*k?\002????I??\005?????????9bz,?nm?/??͛?K?]?!?\nud??4??4??\002?\001?F??!m??0??y??uq%߫"...

8 0x0015a567 in wxInternetFSHandler::OpenFile (this=0x15a50348, location=@0xb0240cfc) at ../src/common/fs_inet.cpp:118

sout = {
= { = { _vptr$wxStreamBase = 0x53b4a8, m_lastcount = 4096, m_lasterror = wxSTREAM_NO_ERROR }, }, members of wxFileOutputStream: m_file = 0x1750c758, m_file_destroy = true } tmpfile = { = { static npos = 4294967295, m_pchData = 0x1750c61c }, } s = (class wxInputStream *) 0x1750ca38 content = { = { static npos = 4294967295, m_pchData = 0x1750cfec }, } right = { = { static npos = 4294967295, m_pchData = 0x1750bdfc }, } url = { = { = { _vptr$wxObject = 0x539a90, static ms_classInfo = { m_className = 0x3a7710, m_objectSize = 8, m_objectConstructor = 0, m_baseInfo1 = 0x0, m_baseInfo2 = 0x0, static sm_first = 0x59d19c, m_next = 0x59aa24, static sm_classTable = 0xa0aa68 }, m_refData = 0x0 }, members of wxURI: m_scheme = { = { static npos = 4294967295, m_pchData = 0x172fa0cc }, }, m_path = { = { static npos = 4294967295, m_pchData = 0x1750c31c }, }, m_query = { = { static npos = 4294967295, m_pchData = 0x3aa8d8 }, }, m_fragment = { = { static npos = 4294967295, m_pchData = 0x3aa8d8 }, }, m_userinfo = { = { static npos = 4294967295, m_pchData = 0x3aa8d8 }, }, m_server = { = { static npos = 4294967295, m_pchData = 0x1750bf7c }, }, m_port = { = { static npos = 4294967295, m_pchData = 0xa22f5c }, }, m_hostType = wxURI_REGNAME, m_fields = 21, static ms_classInfo = { m_className = 0x3ae354, m_objectSize = 44, m_objectConstructor = 0, m_baseInfo1 = 0x59aa3c, m_baseInfo2 = 0x0, static sm_first = 0x59d19c, m_next = 0x59aa98, static sm_classTable = 0xa0aa68 } }, members of wxURL: static ms_protocols = 0x597e80, static ms_proxyDefault = 0x0, static ms_useDefaultProxy = false, m_proxy = 0x0, m_protoinfo = 0x597dc0, m_protocol = 0x1750c418, m_error = wxURL_NOERR, m_url = { = { static npos = 4294967295, m_pchData = 0x1750bdfc }, }, m_useProxy = false, static ms_classInfo = { m_className = 0x38aeac, m_objectSize = 68, m_objectConstructor = 0, m_baseInfo1 = 0x59aacc, m_baseInfo2 = 0x0, static sm_first = 0x59d19c, m_next = 0x597f78, static sm_classTable = 0xa0aa68 } } #9 0x0019d247 in wxFileSystem::OpenFile (this=0x172fa148, location=@0xb0240e70, flags=1) at ../src/common/filesys.cpp:453 h = (wxFileSystemHandler *) 0x15a50348 i = 4 ln = 67 s = (wxFSFile *) 0x0 node = { m_ptr = 0x15a596f8 } loc = { = { static npos = 4294967295, m_pchData = 0x1750c09c }, } meta = 58 #10 0x0032eee3 in AddManager::DownloadImage (this=0x15ae2bb8, imageUrl=@0xb0240e70) at ../src/adds/addmanager.cpp:210 flags = 1 sys = (class wxFileSystem *) 0x172fa148 myFile = (class wxFSFile *) 0xb0240dcc in_stream = (class wxInputStream *) 0x25f255 #11 0x0032f9c0 in AddManager::LoadAdds (this=0x15ae2bb8) at ../src/adds/addmanager.cpp:166 image = (class wxImage *) 0x0 list = { = { = { _vptr$wxObject = 0x51c6e8, static ms_classInfo = { m_className = 0x3a7710, m_objectSize = 8, m_objectConstructor = 0, m_baseInfo1 = 0x0, m_baseInfo2 = 0x0, static sm_first = 0x59d19c, m_next = 0x59aa24, static sm_classTable = 0xa0aa68 }, m_refData = 0x0 }, members of wxListBase: m_count = 11, m_destroy = false, m_nodeFirst = 0x1750bdc8, m_nodeLast = 0x1721ccc8, m_keyType = wxKEY_NONE }, } child = (class wxXmlNode *) 0x0 i = { m_node = 0x1750bdc8, m_init = 0x1721ccc8 } downloadList = { = { = { _vptr$wxObject = 0x51c6e8, static ms_classInfo = { m_className = 0x3a7710, m_objectSize = 8, m_objectConstructor = 0, m_baseInfo1 = 0x0, m_baseInfo2 = 0x0, static sm_first = 0x59d19c, m_next = 0x59aa24, static sm_classTable = 0xa0aa68 }, m_refData = 0x0 }, members of wxListBase: m_count = 0, m_destroy = false, m_nodeFirst = 0x0, m_nodeLast = 0x0, m_keyType = wxKEY_NONE }, } flags = 1 sys = (class wxFileSystem *) 0x15a5d188 myFile = (class wxFSFile *) 0x172222e8 doc = { = { _vptr$wxObject = 0x539228, static ms_classInfo = { m_className = 0x3a7710, m_objectSize = 8, m_objectConstructor = 0, m_baseInfo1 = 0x0, m_baseInfo2 = 0x0, static sm_first = 0x59d19c, m_next = 0x59aa24, static sm_classTable = 0xa0aa68 }, m_refData = 0x0 }, members of wxXmlDocument: m_version = { = { static npos = 4294967295, m_pchData = 0x1721d3ec }, }, m_fileEncoding = { = { static npos = 4294967295, m_pchData = 0x15a5e72c }, }, m_root = 0x15ae36c8, static ms_classInfo = { m_className = 0x388420, m_objectSize = 20, m_objectConstructor = 0, m_baseInfo1 = 0x59aa3c, m_baseInfo2 = 0x0, static sm_first = 0x59d19c, m_next = 0x597c00, static sm_classTable = 0xa0aa68 } } in_stream = (class wxInputStream *) 0x15af0a48 __FUNCTION__ = "LoadAdds" #12 0x0032fd14 in AddManager::Entry (this=0x15ae2bb8) at ../src/adds/addmanager.cpp:68 counter = -1 #13 0x001e8fb8 in wxThreadInternal::MacThreadStart (parameter=0x15ae2bb8) at ../src/mac/carbon/thread.cpp:1062 thread = (wxThread *) 0x15ae2bb8 pthread = (wxThreadInternal *) 0x15af00e8 dontRunAtAll = false #14 0x93518057 in PrivateMPEntryPoint () No symbol table info available. #15 0x97a82155 in _pthread_start () No symbol table info available. #16 0x97a82012 in thread_start () No symbol table info available.
wxtrac commented 14 years ago

2010-07-23 15:06:49: johan.vdberg (Johan van den Berg) commented


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.

wxtrac commented 14 years ago

2010-07-23 15:13:55: @vadz changed status from new to infoneeded_new

2010-07-23 15:13:55: @vadz commented

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.

wxtrac commented 13 years ago

2011-02-13 16:58:12: johan.vdberg (Johan van den Berg) changed status from infoneeded_new to new

2011-02-13 16:58:12: johan.vdberg (Johan van den Berg) commented

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) { +

wxtrac commented 13 years ago

2011-02-19 15:19:21: @vadz commented


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.

2011-02-19 15:19:21: @vadz changed status from new to closed

2011-02-19 15:19:21: @vadz set resolution to duplicate

wxtrac commented 13 years ago

2011-02-19 15:26:51: @vadz commented


(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.