dolphin-emulator/Source/Core
Dentomologist dd1f5f9726 NetKDRequestDevice: Fix use-after-free crash
Explicitly shut down work queues in NetKDRequestDevice's destructor to
prevent their threads from accessing members after they've been freed.

This crash would occur sporadically if NetKDRequestDevice's periodic
download or mail checks happened to overlap with emulation shutdown in
the wrong way.

An example sequence of events that could cause the crash:
* m_scheduler_timer_thread queues a periodic Download event in
  m_scheduler_work_queue, then waits for m_shutdown_event.
* A request to stop emulation results in s_ios being reset by the CPU
  thread. This triggers NetKDRequestDevice's destructor which sets
  m_shutdown_event and joins m_scheduler_timer_thread.
* m_scheduler_timer_thread wakes from m_shutdown_event and returns from
  its thread function, ending the thread.
* The CPU thread resumes execution at the end of NetKDRequestDevice's
  destructor and begins destroying NetKDRequestDevice's members in
  reverse declaration order.
* m_http is declared after m_scheduler_work_queue and is therefore
  destroyed earlier.
* m_scheduler_work_queue's destructor calls its Shutdown function, which
  by default finishes the work items in the queue.
* The queued Download event calls KDDownload which calls m_http.Get()
  which calls Fetch() which passes garbage data from the freed m_curl
  into curl_easy_setopt().
* Curl promptly crashes.

Shutting down the work queues manually in the destructor prevents the
above because m_http and the other members don't get freed until after
the queue threads finish.
2023-12-24 15:04:35 -08:00
..
AudioCommon
Common Merge pull request #12439 from lioncash/sprintf 2023-12-21 17:17:21 -05:00
Core NetKDRequestDevice: Fix use-after-free crash 2023-12-24 15:04:35 -08:00
DiscIO RiivolutionParser: Remove usages of global system accessor 2023-12-12 12:48:40 -05:00
DolphinNoGUI
DolphinQt VideoCommon/Fifo: Pass system instance through FifoManager constructor 2023-12-18 22:03:25 -05:00
DolphinTool Tool/Header: Add JSON output mode; game data 2023-11-28 08:49:28 +00:00
InputCommon Merge pull request #12399 from lioncash/erasing 2023-12-12 20:54:52 +00:00
MacUpdater
UICommon UICommon: Remove global system accessor in TriggerSTMPowerEvent() 2023-12-18 19:17:16 -05:00
UpdaterCommon
VideoBackends VideoCommon: revert max pixel shader samplers back to 8 for Android devices. 2023-12-21 00:36:44 -06:00
VideoCommon VideoCommon/PixelEngine: Generify lock guards 2023-12-22 14:19:29 -05:00
WinUpdater
CMakeLists.txt
DolphinLib.ARM64.props
DolphinLib.props Merge pull request #11497 from vyuuui/debugger_assembler_ui 2023-12-16 21:15:31 +00:00
DolphinLib.vcxproj Add lz4 submodule 2023-10-02 17:28:23 -04:00
DolphinLib.vcxproj.user
DolphinLib.x64.props