Hello,

I just tested the new tests/stress program. The first execution is a
success since I get a crash :-}
I am using Mac OS X Mountain Lion (10.8.2)

$ glibtool --mode=execute gdb stress
GNU gdb 6.3.50-20050815 (Apple version gdb-1822) (Sun Aug  5 03:00:42 UTC 2012)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for
shared libraries ...... done

(gdb) set args -v default_context_change
(gdb) set environment LIBUSB_DEBUG 99
(gdb) r
Starting program:
/Users/rousseau/Documents/github/libusbx/tests/.libs/stress -v
default_context_change
Reading symbols for shared libraries
+++++.................................. done
Starting test run: default_context_change...
libusbx: debug [libusb_init] created default context
libusbx: debug [libusb_init] libusbx v1.0.14.10589
libusbx: debug [event_thread_main] creating hotplug event source
libusbx: debug [event_thread_main] thread ready to receive events
libusbx: debug [usbi_add_pollfd] add fd 5 events 1
libusbx: debug [libusb_init] reusing default context
libusbx: debug [libusb_exit]
libusbx: debug [libusb_exit] destroying default context

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000068
libusb_exit (ctx=0x60) at core.c:1729
1729            if (!list_empty(&ctx->open_devs))
(gdb) bt
#0  libusb_exit (ctx=0x60) at core.c:1729
#1  0x0000000100001341 in test_default_context_change
(tctx=0x7fff5fbff3d0) at stress.c:143
#2  0x00000001000017ce in libusbx_testlib_run_tests (argc=1027,
argv=0x7fff5fbff420, tests=0x7fff5fbff420) at testlib.c:232
#3  0x00007fff94c257e1 in start ()
(gdb)

The crash is caused by calling libusb_exit(NULL); line 143 of stress.c

The first call to libusb_init(&ctx); will create a context and make it
the default context.
Then the call to libusb_init(NULL); will reuse the default context.

libusb_exit(ctx); will then destroy the context ctx _and_ also detroy
the default context.
libusb_exit(NULL); will try to reuse the default context but this one
is already destroyed.

The test comment is exact:
/** Tests that the default context (used for various things including
 * logging) works correctly when the first context created in a
 * process is destroyed. */

The answer is that it does not work.

Does this test pass on Windows?

Bye,

-- 
 Dr. Ludovic Rousseau

------------------------------------------------------------------------------
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

Reply via email to