{subsection: <SUBSYS>_WAIT_FOR_DEBUGGER} In addition to <SUBSYS>_DEBUG_WAIT, on Windows (#ifdef WIN32) you have access to <SUBSYS>_WAIT_FOR_DEBUGGER. It's very similar, but is smart enough to automatically detect when a debugger is attached. + +{subsection: Using the Windows heap verifier} + +The Windows SDK includes a bunch of Debugging Tools For Windows, one of which is the heap verifier. I can detect heap corruption early and provide a stack trace at or near the corrupting code. To do this you will need to install +http://www.microsoft.com/en-us/download/confirmation.aspx?id=8279 to get gflags and cdb/ntsd + +The steps are: +*: use gflags to turn on heap checking for the demon +*: replace the daemon with a script that runs the daemon under the debugger +*: start condor. when the daemon starts up, attach to the debugger and hit 'g' to let the daemon begin running. + +You an replace the daemon with a batch script like this one, which replaces the condor_starter. save this as =c:\condor\bin\debug_condor_starter.bat= +{code} +@echo off +@setlocal +@if NOT "%1"=="-classad" goto :job +@REM just run the starter normally +%~dp0condor_starter.exe %* +@goto :EOF +:job +@REM echo %* > c:\condor\log\starterargs +set remote=-server tcp:port=5099:6000 +set log=-logo c:\condor\log\DStarterLog +::set nobreak=-g +set _NT_SYMBOL_PATH=c:\condor\bin;SRV*C:\Symbols*http://msdl.microsoft.com/download/symbols +"C:\Program Files\Debugging Tools for Windows (x64)\cdb.exe" %remote% %log% -x %nobreak% %~dp0condor_starter.exe %* +{endcode} + +And add this to your configuration +{code}STARTER = $(BIN)\debug_condor_starter.bat{endcode} + +Startup a command prompt with run-as-administrator and execute: +{code}"C:\Program Files\Debugging Tools for Windows (x64)\gflags" /p /enable condor_starter.exe {endcode} +or this, to get full verification at every call (it's a bit slower) +{code}"C:\Program Files\Debugging Tools for Windows (x64)\gflags" /p /enable condor_starter.exe /full{endcode} + +Start HTCondor, once the daemon starts up, run this command +{code}"C:\Program Files\Debugging Tools for Windows (x64)\cdb" -remote tcp:port=5099:6000{endcode} +This will attach to the cdb instance that is debugging the daemon. Unless you had =nobreak= set in the script above, the debugger will be broken and the daemon will not yet have started. run the folling commands to run the daemon +{code} +.lines +g +{endcode} +when the heap verifier finds a problem the 'k' command will produce a stack trace.