| 194 | |
| 195 | |
| 196 | void DbgEngTTDAdapter::Reset() |
| 197 | { |
| 198 | m_aboutToBeKilled = false; |
| 199 | |
| 200 | if (!this->m_debugActive) |
| 201 | return; |
| 202 | |
| 203 | // Free up the resources if the dbgsrv is launched by the adapter. Otherwise, the dbgsrv is launched outside BN, |
| 204 | // we should keep everything active. |
| 205 | SAFE_RELEASE(this->m_debugControl); |
| 206 | SAFE_RELEASE(this->m_debugDataSpaces); |
| 207 | SAFE_RELEASE(this->m_debugRegisters); |
| 208 | SAFE_RELEASE(this->m_debugSymbols); |
| 209 | SAFE_RELEASE(this->m_debugSystemObjects); |
| 210 | |
| 211 | if (this->m_debugClient) |
| 212 | { |
| 213 | this->m_debugClient->EndSession(DEBUG_END_PASSIVE); |
| 214 | m_server = 0; |
| 215 | } |
| 216 | |
| 217 | // There seems to be an internal ref-counting issue in the DbgEng TTD engine, that the reference for the debug |
| 218 | // client is not properly freed after the target has exited. To properly free the debug client instance, here we |
| 219 | // are calling Release() a few more times to ensure the ref count goes down to 0. Luckily this would not cause |
| 220 | // a UAF or crash. |
| 221 | // This might be related to the weird behavior of not terminating the target when we call TerminateProcesses(), |
| 222 | // (see comment in `DbgEngTTDAdapter::Quit()`). |
| 223 | // The same issue is not observed when we do forward debugging using the regular DbgEng. Also, I cannot reproduce |
| 224 | // the issue using my script https://github.com/xusheng6/dbgeng_test. |
| 225 | for (size_t i = 0; i < 100; i++) |
| 226 | m_debugClient->Release(); |
| 227 | |
| 228 | SAFE_RELEASE(this->m_debugClient); |
| 229 | |
| 230 | this->m_debugActive = false; |
| 231 | } |
| 232 | |
| 233 | |
| 234 | bool DbgEngTTDAdapter::Quit() |
no test coverage detected