Closed GoogleCodeExporter closed 8 years ago
Looking at the code, I think the problem is that I'm removing CFDictionary
items from the callback of a Dictionary iterator function. And this is unsafe
according to Apple's CF API.
I probably miseed this in the past because the device removal flow is clumsy.
It can happen a device at a time, or all at once, and the dictionary removal
step is two steps removed from the iterator callback.
Original comment by Benjamin.Heasly
on 16 Aug 2010 at 11:19
So, there are three things that need to happen to each device, in either case:
- close the device with the HID API
- release the device info stored in the mexHID struct
- remove the dictionary entry that contains the mexHID struct
But in the case of mexHIDTerminate, there's no point in removing all the
dictionary entries, since the dictionary itself is about to be destroyed.
So I need to back the dictionary removal out to only happen when the user calls
for mexHIDCloseDevice. And the iterator should not call mexHIDCloseDevice.
Original comment by Benjamin.Heasly
on 16 Aug 2010 at 11:26
I think I have fixed this.
I didn't "back out" the dictionary removal because I had made parallel
implementations for openDevice/closeDevice, and retainDevice/releaseDevices.
So instead the dictionary iterator callback does the HID API close and the
mexHID info struct release on its own, and does not modify the dictionary
itself.
Original comment by Benjamin.Heasly
on 16 Aug 2010 at 11:47
Original issue reported on code.google.com by
Benjamin.Heasly
on 16 Aug 2010 at 10:59Attachments: