On 25/11/12 22:43, Pete Batard wrote:
It was mentioned that the stress test fails on Windows and Linux as well.
Linux:
# ./tests/stress
Starting test run: init_and_exit...
Success (0)
Starting test run: get_device_list...
Success (0)
Starting test run: many_device_lists...
Success (0)
Starting test run: default_context_change...
Segmentation fault
Windows:
>stress
Starting test run: init_and_exit...
Success (0)
Starting test run: get_device_list...
Success (0)
Starting test run: many_device_lists...
Failed to get device list on iteration 32: 4 (00000000)
Failure (1)
Starting test run: default_context_change...
<crashes>
That last crash seems to be a cross platform issue. And the device_list
one is probably linked to the 32 maxout we've seen for HID.
It turns out the reference counting for the default context was slightly
off, introduced by this commit:
https://github.com/libusbx/libusbx/commit/cf6e68acb116c63f4a8c9d30ee4f2757e8c2e12a
It moved the setting of usbi_default_context to earlier in the method,
but didn't increment the reference count.
I've attached a patch to fix the issue.
Regards,
Toby
>From a5fc0179ffdc8c015d83ff348f18ad20acc22da3 Mon Sep 17 00:00:00 2001
From: Toby Gray <toby.g...@realvnc.com>
Date: Mon, 26 Nov 2012 13:25:05 +0000
Subject: [PATCH] Core: Fix incorrect reference counting of default context when first created.
---
libusb/core.c | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/libusb/core.c b/libusb/core.c
index 07b0b04..729bce3 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -1655,6 +1655,7 @@ int API_EXPORTED libusb_init(libusb_context **context)
/* default context should be initialized before calling usbi_dbg */
if (!usbi_default_context) {
usbi_default_context = ctx;
+ default_context_refcnt++;
usbi_dbg("created default context");
}
@@ -1681,10 +1682,6 @@ int API_EXPORTED libusb_init(libusb_context **context)
if (context) {
*context = ctx;
- } else if (!usbi_default_context) {
- usbi_dbg("created default context");
- usbi_default_context = ctx;
- default_context_refcnt++;
}
usbi_mutex_static_unlock(&default_context_lock);
--
1.7.0.4
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel