HHVM Debugger: Fix hang in debugger extension shutdown
commitf6ee88841e56472d7765b48ee668fcc7957ccf54
authorEric Bluestein <ericblue@fb.com>
Tue, 31 Jul 2018 18:09:53 +0000 (31 11:09 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Tue, 31 Jul 2018 18:14:04 +0000 (31 11:14 -0700)
treedc4917cf42e2c454e7ed18b25748bbd8965a4055
parent95d1d275beee5213618f48ae0225251f648b6d1f
HHVM Debugger: Fix hang in debugger extension shutdown

Summary:
This fixes a race preventing the debugger extension from shutting down cleanly.

The session cleanup thread deletes sessions in an async job because the session thread can be blocked running user code (its the HPHP request backing the console REPL). It therefore can block indefinitely if the user has called into a native method or has an infinite loop etc, and so we can't wait to join to it on the thread that needs to communicate with the debugger client.

If this thread is cleaning up sessions due to the client disconnecting, and the extension shutdown thread signals m_sessionCleanupCondition before the cleanup thread re-acquires the lock, we can erroneously go to sleep again because we're failing to re-check m_sessionCleanupTerminating after re-acquiring the lock but before sleeping on the condition variable.

Reviewed By: alexeyt

Differential Revision: D9038429

fbshipit-source-id: 67fe04876b0f4845cb5ff9418d301cf192ddcc75
hphp/runtime/ext/vsdebug/debugger.cpp