| commit | ec01c28e1e892b410bdd1581a2bd4e46cbd03eac | [log] [tgz] |
|---|---|---|
| author | Chris Dickens <christopher.a.dickens@gmail.com> | Mon Mar 02 16:23:45 2020 -0800 |
| committer | Chris Dickens <christopher.a.dickens@gmail.com> | Thu Mar 05 22:47:52 2020 -0800 |
| tree | 49091b5b2893cfe5c40abd5593daad31343c789c | |
| parent | 281ca64c8ac9b9ee6ec72f2b776016aa98e964ba [diff] |
darwin: Fix race condition that results in segmentation fault
Commit 763668cc92 ("darwin: fix occasional dead-lock on libusb_exit")
resolved the deadlock situation observed in #112, but unfortunately
there is a very rare race condition that can occur when the asynchronous
event thread exits the run loop before CFRunLoopWakeUp() is called. This
can occur when the shutdown source signal is processed as part of other
events in the run loop, in which case the thread was already "awake".
Prior to this change I was able to consistently trigger a segmentation
fault within 10,000 iterations of a libusb_init()/libusb_exit() loop.
With this change I reached over 4 million iterations without issue.
Closes #701
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb is a library for USB device access from Linux, macOS, Windows, OpenBSD/NetBSD and Haiku userspace. It is written in C (Haiku backend in C++) and licensed under the GNU Lesser General Public License version 2.1 or, at your option, any later version (see COPYING).
libusb is abstracted internally in such a way that it can hopefully be ported to other operating systems. Please see the PORTING file for more information.
libusb homepage: http://libusb.info/
Developers will wish to consult the API documentation: http://api.libusb.info
Use the mailing list for questions, comments, etc: http://mailing-list.libusb.info
(Please use the mailing list rather than mailing developers directly)