Browse Source

device: Fix macOS crash when unplugging device in threaded pipeline

Fixes #1082
rdb 5 years ago
parent
commit
55d43a1d57
2 changed files with 3 additions and 0 deletions
  1. 1 0
      doc/ReleaseNotes
  2. 2 0
      panda/src/device/inputDeviceManager.cxx

+ 1 - 0
doc/ReleaseNotes

@@ -4,6 +4,7 @@ Recommended maintenance release.
 
 
 * Support building for macOS 11 "Big Sur" and "Apple Silicon" (arm64)
 * Support building for macOS 11 "Big Sur" and "Apple Silicon" (arm64)
 * Fix a memory leak, particularly noticeable with multithreaded pipeline (#1077)
 * Fix a memory leak, particularly noticeable with multithreaded pipeline (#1077)
+* Fix crash on macOS when unplugging device with threading active (#1082)
 * Fix error with build_apps not working with certain versions of Python
 * Fix error with build_apps not working with certain versions of Python
 * Fix DirectEntry/PGEntry flickering in the multithreaded pipeline (#1070)
 * Fix DirectEntry/PGEntry flickering in the multithreaded pipeline (#1070)
 * Fix sounds resuming on reactivation if stop() was called while inactive (#559)
 * Fix sounds resuming on reactivation if stop() was called while inactive (#559)

+ 2 - 0
panda/src/device/inputDeviceManager.cxx

@@ -111,6 +111,8 @@ add_device(InputDevice *device) {
  */
  */
 void InputDeviceManager::
 void InputDeviceManager::
 remove_device(InputDevice *device) {
 remove_device(InputDevice *device) {
+  // We need to hold a reference, since remove_device decrements the refcount.
+  PT(InputDevice) device_ref = device;
   {
   {
     LightMutexHolder holder(_lock);
     LightMutexHolder holder(_lock);
     _connected_devices.remove_device(device);
     _connected_devices.remove_device(device);