VirtualBox

Ticket #12349 (closed defect: fixed)

Opened 5 months ago

Last modified 5 months ago

Deadlock at HostDnsServiceLinux::init() due to race condition on signaling/waiting g_DnsInitEvent => Fixed in SVN

Reported by: dennis.c Owned by:
Priority: critical Component: host support
Version: VirtualBox 4.3.2 Keywords: deadlock HostDnsService HostDnsServiceLinux race condition
Cc: Guest type: all
Host type: Linux

Description

HostDnsServiceLinux::init (at HostDnsServiceLinux.cpp:176) seemed to wait for the g_DnsInitEvent infinitely since the hostMonitoringRoutine thread had successfully signaled the g_DnsInitEvent (at HostDnsServiceLinux.cpp:133).
Thus, the whole VBoxSVC was stuck forever.

164 HRESULT HostDnsServiceLinux::init(const char *aResolvConfFileName)
165 {
166     HRESULT hrc = HostDnsServiceResolvConf::init(aResolvConfFileName);
167     AssertComRCReturnRC(hrc);
168 
169     int rc = RTThreadCreate(&g_DnsMonitoringThread, HostDnsServiceLinux::hostMonitoringRoutine,
170                             this, 128 * _1K, RTTHREADTYPE_IO, 0, "dns-monitor");
171     AssertRCReturn(rc, E_FAIL);
172 
173     rc = RTSemEventCreate(&g_DnsInitEvent);
174     AssertRCReturn(rc, E_FAIL);
175 
176     RTSemEventWait(g_DnsInitEvent, RT_INDEFINITE_WAIT);
177 
178     return S_OK;
179 }
111 int HostDnsServiceLinux::hostMonitoringRoutine(RTTHREAD ThreadSelf, void *pvUser)
........
132 
133     RTSemEventSignal(g_DnsInitEvent);
134 
135     while(true)
136     {
137         rc = poll(polls, 2, -1);
138         if (rc == -1)
139             continue;

gdb stack trace on related threads listed as follows:

Thread 3 (Thread 0x401e5940 (LWP 3645)):
#0  0x00000031478cb696 in poll () from /lib64/libc.so.6
#1  0x00000000006428a6 in HostDnsServiceLinux::hostMonitoringRoutine (ThreadSelf=<value optimized out>, pvUser=0x986720) at /home/build/VirtualBox-4.3.2/src/VBox/Main/src-server/linux/HostDnsServiceLinux.cpp:137
#2  0x00002ab4eedce01c in rtThreadMain (pThread=0x98fd90, NativeThread=<value optimized out>, pszThreadName=<value optimized out>) at /home/build/VirtualBox-4.3.2/src/VBox/Runtime/common/misc/thread.cpp:712
#3  0x00002ab4eee2c7ad in rtThreadNativeMain (pvArgs=<value optimized out>) at /home/build/VirtualBox-4.3.2/src/VBox/Runtime/r3/posix/thread-posix.cpp:324
#4  0x000000314840673d in start_thread () from /lib64/libpthread.so.0
#5  0x00000031478d44bd in clone () from /lib64/libc.so.6


Thread 7 (Thread 0x40041940 (LWP 3623)):
#0  0x00000031478d0f69 in syscall () from /lib64/libc.so.6
#1  0x00002ab4eee2eb9c in sys_futex (uaddr=0x985b28, op=0, val=0, utime=0x0, uaddr2=0x0, val3=0) at /home/build/VirtualBox-4.3.2/src/VBox/Runtime/r3/linux/semevent-linux.cpp:107
#2  0x00002ab4eee2ec7e in rtSemEventWait (hEventSem=0x985b20, cMillies=4294967295, fAutoResume=true) at /home/build/VirtualBox-4.3.2/src/VBox/Runtime/r3/linux/semevent-linux.cpp:300
#3  0x0000000000642640 in HostDnsServiceLinux::init (this=0x986720, aResolvConfFileName=<value optimized out>) at /home/build/VirtualBox-4.3.2/src/VBox/Main/src-server/linux/HostDnsServiceLinux.cpp:176
#4  0x000000000048ead7 in HostDnsMonitor::getHostDnsMonitor () at /home/build/VirtualBox-4.3.2/src/VBox/Main/src-server/HostDnsService.cpp:122
#5  0x000000000049effa in Host::init (this=0x980ba0, aParent=0x96d200) at /home/build/VirtualBox-4.3.2/src/VBox/Main/src-server/HostImpl.cpp:297
#6  0x00000000005a41bc in VirtualBox::init (this=0x96d200) at /home/build/VirtualBox-4.3.2/src/VBox/Main/src-server/VirtualBoxImpl.cpp:427
#7  0x0000000000616b6b in GetInstance (aOuter=<value optimized out>, aIID=..., aResult=0x40040fd0) at /home/build/VirtualBox-4.3.2/src/VBox/Main/src-server/xpcom/server.cpp:538
#8  VirtualBoxConstructor (aOuter=<value optimized out>, aIID=..., aResult=0x40040fd0) at /home/build/VirtualBox-4.3.2/src/VBox/Main/src-server/xpcom/server.cpp:610
#9  0x00002ab4ef2a16c7 in nsGenericFactory::CreateInstance (this=<value optimized out>, aOuter=0x0, aIID=..., aResult=0xffffffffffffffff) at /home/build/VirtualBox-4.3.2/src/libs/xpcom18a4/xpcom/glue/nsGenericFactory.cpp:82
#10 0x00002ab4ef26c058 in nsComponentManagerImpl::CreateInstance (this=0x949fc0, aClass=<value optimized out>, aDelegate=0x0, aIID=..., aResult=0x40040fd0) at /home/build/VirtualBox-4.3.2/src/libs/xpcom18a4/xpcom/components/nsComponentManager.cpp:1876
#11 0x00002aaaaacdb435 in ipcDConnectService::OnSetup (this=0x96b9f0, peer=2, setup=0x96e150, opLen=<value optimized out>) at /home/build/VirtualBox-4.3.2/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnect Service.cpp:3686
#12 0x00002aaaaacdd055 in ipcDConnectService::OnIncomingRequest (this=0x985b28, peer=0, op=0x0, opLen=4294967295) at /home/build/VirtualBox-4.3.2/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp:3657
#13 0x00002aaaaacdd248 in DConnectWorker::Run (this=0x96c660) at /home/build/VirtualBox-4.3.2/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp:2968
#14 0x00002ab4ef270f96 in nsThread::Main (arg=0x96bc20) at /home/build/VirtualBox-4.3.2/src/libs/xpcom18a4/xpcom/threads/nsThread.cpp:118
#15 0x00002ab4ef28434e in _pt_root (Thread=<value optimized out>, pvUser=<value optimized out>) at /home/build/VirtualBox-4.3.2/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptthread.c:224
#16 _pt_iprt_root (Thread=<value optimized out>, pvUser=<value optimized out>) at /home/build/VirtualBox-4.3.2/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptthread.c:272
#17 0x00002ab4eedce01c in rtThreadMain (pThread=0x96c8a0, NativeThread=<value optimized out>, pszThreadName=<value optimized out>) at /home/build/VirtualBox-4.3.2/src/VBox/Runtime/common/misc/thread.cpp:712
#18 0x00002ab4eee2c7ad in rtThreadNativeMain (pvArgs=<value optimized out>) at /home/build/VirtualBox-4.3.2/src/VBox/Runtime/r3/posix/thread-posix.cpp:324
#19 0x000000314840673d in start_thread () from /lib64/libpthread.so.0
#20 0x00000031478d44bd in clone () from /lib64/libc.so.6

Change History

comment:1 Changed 5 months ago by frank

  • Summary changed from Deadlock at HostDnsServiceLinux::init() due to race condition on signaling/waiting g_DnsInitEvent to Deadlock at HostDnsServiceLinux::init() due to race condition on signaling/waiting g_DnsInitEvent => Fixed in SVN

Thank you for this report and your analysis! Actually this was a race: The semevent was initialized after the thread was created. Fixed in trunk (r49459 and r49460) and in the next 4.3.x maintenance release.

comment:2 Changed 5 months ago by frank

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

Fixed in 4.3.4.

Note: See TracTickets for help on using tickets.

www.oracle.com
ContactPrivacy policyTerms of Use