staticanalysis / data-race-test

Automatically exported from code.google.com/p/data-race-test
0 stars 0 forks source link

Handle RegisterWaitForSingleObject/UnregisterWaitEx correctly #24

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
See NegativeTests.RegisterWaitForSingleObjectTest (disable atm)
in unittest/windows_tests.cc

--------------------------------------------------------
FYI, the list of functions called by the thread from the 
RegisterWaitForSingleObject pool is:
BaseThreadInitThunk
GetModuleHandleW
NtContinue
NtTestAlert
NtWaitForSingleObject
NtWorkerFactoryWorkerReady
RtlAcquireSRWLockShared
RtlCreateUserProcess
RtlDllShutdownInProgress
RtlGetCurrentPeb
RtlImageNtHeader
RtlImageNtHeaderEx
RtlInitializeExceptionChain
RtlIsActivationContextActive
RtlIsCriticalSectionLockedByThread
RtlIsCurrentThreadAttachExempt
RtlNtStatusToDosError
RtlNtStatusToDosErrorNoTeb
RtlProcessFlsData
RtlQueryElevationFlags
RtlRegisterThreadWithCsrss
RtlSleepConditionVariableSRW
RtlTimeToTimeFields
RtlpInterlockedPopEntrySeqSListEnd
SetLastError
TpPostWork
TpReleaseTimer
ZwAllocateVirtualMemory
_lock
_unlock

Original issue reported on code.google.com by timurrrr on 24 Feb 2010 at 3:07

GoogleCodeExporter commented 9 years ago
+ NegativeTests.QueueUserWorkItemTest

Original comment by timurrrr on 24 Feb 2010 at 4:09

GoogleCodeExporter commented 9 years ago
I hope this is fixed now, tests are enabled. 

Original comment by konstant...@gmail.com on 1 Mar 2010 at 8:32

GoogleCodeExporter commented 9 years ago
Seems like the happens-before arcs may still be missed when using 
::UnregisterWaitEx

Attached are the binaries of net_unittests, run with
C:/pin/ia32/bin/pin.exe -t x86-windows-ts_pin.dll -short_name 
--ignore=ignores.txt --
ignore=ignores_win32.txt --pure-happens-before=yes --ignore-in-dtor=no 
--announce-
threads --suppressions=suppressions.txt --suppressions=suppressions_win32.txt --
debug_phase=thread -- net_unittests --gtest_filter=*TCP*:*Telnet*:*Transaction*

The reports are from TCPPinger tests, but I couldn't reproduce them with 
smaller 
gtest_filter

Original comment by timurrrr on 17 Mar 2010 at 3:39

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by timurrrr on 17 Mar 2010 at 3:40

GoogleCodeExporter commented 9 years ago
--gtest_filter=*TCPPinger*:*Telnet*:*Transaction*:-*Large* is fine (1.5x faster)

chrome svn rev 41575

Original comment by timurrrr on 17 Mar 2010 at 3:50

GoogleCodeExporter commented 9 years ago
Report:
INFO: T7 has been created by T0 at this point: {{{
    #0   
    #1  NtWaitForSingleObject C:\Windows\SysWOW64\ntdll.dll
    #2  WaitForSingleObjectEx C:\Windows\syswow64\kernel32.dll
    #3  WaitForSingleObject C:\Windows\syswow64\kernel32.dll
    #4  base::WaitableEvent::Wait base\waitable_event_win.cc:50
    #5  base::Thread::StartWithOptions base\thread.cc:93
    #6  net::TCPPinger::TCPPinger net\socket\tcp_pinger.h:37
    #7  TCPPingerTest_PingFail_Test::TestBody net\socket\tcp_pinger_unittest.cc:92
}}}
INFO: T0 is program's main thread
INFO: T2 has been created by T0 at this point: {{{
    #0  RtlTryEnterCriticalSection C:\Windows\SysWOW64\ntdll.dll
    #1  RtlFreeAnsiString C:\Windows\SysWOW64\ntdll.dll
    #2  RtlFreeAnsiString C:\Windows\SysWOW64\ntdll.dll
    #3  RtlTimeToTimeFields C:\Windows\SysWOW64\ntdll.dll
    #4  TpReleaseTimer C:\Windows\SysWOW64\ntdll.dll
    #5  TpReleaseTimer C:\Windows\SysWOW64\ntdll.dll
    #6  TpAllocWait C:\Windows\SysWOW64\ntdll.dll
    #7  RtlRegisterWait C:\Windows\SysWOW64\ntdll.dll
    #8  RtlRegisterWait C:\Windows\SysWOW64\ntdll.dll
    #9  RegisterWaitForSingleObject C:\Windows\syswow64\kernel32.dll
    #10 base::ObjectWatcher::StartWatching base\object_watcher.cc:61
    #11 ListenSocket::WatchSocket net\base\listen_socket.cc:198
}}}
WARNING: Possible data race during read of size 1 at 2983E48C: {{{
   T7 (locks held: {}):
    #0  base::ObjectWatcher::StopWatching base\object_watcher.cc:101
    #1  net::TCPClientSocketWin::Core::~Core net\socket\tcp_client_socket_win.cc:226
    #2  net::TCPClientSocketWin::Core::`scalar deleting destructor' C:\Users\timurrrr\Desktop\tests\net_unittests.exe
    #3  base::RefCounted<net::TCPClientSocketWin::Core>::Release base\ref_counted.h:93
    #4  scoped_refptr<net::TCPClientSocketWin::Core>::operator= base\ref_counted.h:261
    #5  net::TCPClientSocketWin::Disconnect net\socket\tcp_client_socket_win.cc:405
    #6  net::TCPClientSocketWin::~TCPClientSocketWin net\socket\tcp_client_socket_win.cc:287
    #7  net::TCPClientSocketWin::`scalar deleting destructor' C:\Users\timurrrr\Desktop\tests\net_unittests.exe
    #8  scoped_ptr<net::TCPClientSocketWin>::reset base\scoped_ptr.h:81
    #9  net::TCPPinger::Worker::DoDisconnect net\socket\tcp_pinger.h:98
    #10 DispatchToMethod<net::TCPPinger::Worker,void (__thiscall net::TCPPinger::Worker::*)(void)> base\tuple.h:412
    #11 RunnableMethod<net::TCPPinger::Worker,void (__thiscall net::TCPPinger::Worker::*)(void),Tuple0>::Run base\task.h:296
  Concurrent write(s) happened at (OR AFTER) these points:
   T2 (locks held: {}):
    #0  base::ObjectWatcher::DoneWaiting base\object_watcher.cc:121
    #1  RtlSetTimer C:\Windows\SysWOW64\ntdll.dll
    #2  RtlSetTimer C:\Windows\SysWOW64\ntdll.dll
    #3  TpReleaseTimer C:\Windows\SysWOW64\ntdll.dll
    #4  RtlMultiByteToUnicodeSize C:\Windows\SysWOW64\ntdll.dll
    #5  TpCallbackMayRunLong C:\Windows\SysWOW64\ntdll.dll
    #6  BaseThreadInitThunk C:\Windows\syswow64\kernel32.dll
  Location 2983E48C is 44 bytes inside a block starting at 2983E460 of size 48 allocated by T7 from heap:
    #0  base::ObjectWatcher::StartWatching base\object_watcher.cc:43
    #1  net::TCPClientSocketWin::Core::WatchForRead net\socket\tcp_client_socket_win.cc:239
    #2  net::TCPClientSocketWin::DoConnect net\socket\tcp_client_socket_win.cc:366
    #3  net::TCPClientSocketWin::Connect net\socket\tcp_client_socket_win.cc:305
    #4  net::TCPPinger::Worker::DoConnect net\socket\tcp_pinger.h:90
    #5  DispatchToMethod<net::TCPPinger::Worker,void (__thiscall net::TCPPinger::Worker::*)(void)> base\tuple.h:412
    #6  RunnableMethod<net::TCPPinger::Worker,void (__thiscall net::TCPPinger::Worker::*)(void),Tuple0>::Run base\task.h:296
    #7  MessageLoop::RunTask base\message_loop.cc:329
    #8  MessageLoop::DeferOrRunPendingTask base\message_loop.cc:337
    #9  MessageLoop::DoWork base\message_loop.cc:444
}}}

Original comment by timurrrr on 18 Mar 2010 at 11:38

Attachments:

GoogleCodeExporter commented 9 years ago
r1863 and r1864 fixed it (hopefully). 

Original comment by konstant...@gmail.com on 18 Mar 2010 at 12:57