Menu

Application Verifier break message

Race condition detected while using a printer handle

Probable cause

A printer handle is being used concurrently in multiple threads.

Printer handles are not thread safe which means that simultaneous use of a printer handle in multiple threads is not permitted without application-level synchronization to safely coordinate access to the handle. The application should either open a separate printer handle in each thread or provide custom synchronization access to the printer handle by using the Microsoft Win32 synchronization API.

The Win32 synchronization API is described further at http://go.microsoft.com/fwlink/?LinkId=68570.

Troubleshooting steps

The sample debugger output below illustrates the following troubleshooting steps:

  • Verify the stack trace of each thread that used that printer handle by using the k command. These threads are described by parameters 2 and 3 of the Verifier Stop.

  • Dump the stack trace for each suspected thread and locate the routine that accessed the printer handle

  • Review the source code of the suspected routines to identify what allowed the concurrent access.

Copy Code
=======================================
VERIFIER STOP 0000A003 : pid 0xAB4: Race condition detected while using a printer handle

        078EAF84 : Printer handle being accessed.
        0000098C : Current thread id.
        00000944 : Thread id of the concurrent thread.
        00000002 : Concurrency count.
=======================================

* List the threads:
*    thread id 98C is the current thread, Param 2 (Note �.� denotes current thread)
*    thread id 944 in the concurrent thread, Param 3

0:002> ~
   0  Id: ab4.2c0 Suspend: 1 Teb: 7ffde000 Unfrozen
   1  Id: ab4.b24 Suspend: 1 Teb: 7ffdd000 Unfrozen
.  2  Id: ab4.98c Suspend: 1 Teb: 7ffdc000 Unfrozen*Suspect thread #1
   3  Id: ab4.944 Suspend: 1 Teb: 7ffdb000 Unfrozen*Suspect thread #2
   4  Id: ab4.8d4 Suspend: 1 Teb: 7ffd9000 Unfrozen
   5  Id: ab4.bcc Suspend: 1 Teb: 7ffda000 Unfrozen
   7  Id: ab4.ca4 Suspend: 1 Teb: 7ffd7000 Unfrozen
   8  Id: ab4.e6c Suspend: 1 Teb: 7ffd6000 Unfrozen

* The debugger is on the 2nd thread as indicated by the 0:002> command prompt
* Use the k command to dump the stack of this thread or use the ~2s command to 
*   change threads

0:002> k
ChildEBP RetAddr
04d0da3c 73de3855 ntdll!DbgBreakPoint
04d0dc40 73cf625e vrfcore!VerifierStopMessageEx+0x4bd
04d0dc64 73cf70f7 vfprint!CHandleTracker_t<void *>::CheckConcurentUse+0x34
04d0dc7c 73cf7caa vfprint!CResourceUsageMgr<void *,CHandleTracker_t<void *> >::PreHandleApiCallHelper+0x2a
04d0dc98 00a5ce5c vfprint!VfHookWritePrinter+0x33
04d0dcb0 00a70779 PrintFilterPipelineSvc!SplReadWrite::SequentialSpoolReaderWriter::Write+0x26 *Suspect routine
04d0dccc 00a63193 PrintFilterPipelineSvc!XpsStreamToPipelineStream::Receive+0x1f

* Switch to concurrent thread, 3 in this case, by using the ~ thread command
0:003> ~3s
eax=c0c0c0c0 ebx=0a344ef4 ecx=00000008 edx=00000000 esi=06110eb0 edi=0a344e88
eip=77c2d804 esp=042ef29c ebp=042ef2c8 iopl=0         nv up ei pl zr na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246
ntdll!KiFastSystemCallRet:
77c2d804 c3              ret

* and dump the stack of the concurrent thread by using the k command
0:005> k
ChildEBP RetAddr
042ef298 77c2bbbc ntdll!KiFastSystemCallRet
042ef29c 77717df9 ntdll!ZwAlpcSendWaitReceivePort+0xc
042ef2c8 7770396d RPCRT4!LRPC_CASSOCIATION::AlpcSendWaitReceivePort+0x24
042ef304 77786b13 RPCRT4!LRPC_CCALL::SendReceive+0x177
042ef314 7779221f RPCRT4!LRPC_CCALL_AVRF::SendReceive+0x26
042ef800 7136680a RPCRT4!NdrClientCall2+0xc49
042ef81c 7135ced1 WINSPOOL!RpcEndDocPrinter+0x1a
042ef860 73cf7fd4 WINSPOOL!EndDocPrinter+0xed
042ef878 00a5a61a vfprint!VfHookEndDocPrinter+0x36
042ef890 00a5a808  PrintFilterPipelineSvc!SplPipeline::SplFilterPipelineCallObject::CleanSpoolerHandles+0x3e *Suspect routine
042ef8a4 77c0fdbd PrintFilterPipelineSvc!SplPipeline::SplFilterPipelineCallObject::CallSignalInMtaThread+0x25
042ef908 77c36b1c ntdll!RtlpTpWorkCallback+0xbf
042efa30 765a333d ntdll!TppWorkerThread+0x522
042efa3c 77c0a8d5 KERNEL32!BaseThreadInitThunk+0xe
042efa7c 00000000 ntdll!_RtlUserThreadStart+0x23

Information displayed by Application Verifier

Parameter 1 - Printer handle being accessed.

Parameter 2 - Current thread id.

Parameter 3 - Thread id of the concurrent thread.

Parameter 4 - Concurrency count.

Additional information

Test Layer:�PrintAPI

Stop code:�0000A003

Severity:�Error

One-time error:�no

Error report:�Break

Log to file:�yes

Create backtrace:�yes