Multiple usbd_connect/usbd_disconnect causes crash?

I’ve ran into some problems using the usb library. I’m running the
devu-uhci driver. If I disconnect from the usb stack I can’t reconnect
without the library generating a SIGSEGV. The backtrace in DDD locks
like this
#3 0x080489c4 in main () at main.cpp:42
#2 0xb8205f3e in ?? () from libusbdi.so.2
#1 0xb8204db5 in ?? () from libusbdi.so.2
#0 0xb0317424 in ?? () from libc.so.2

The connection structures are the same as the one supplied in the
example in the usbd_connect documentation except that the 3Com stuff has
been replaced with USBD_CONNECT_WILDCARD and I supply argc = 0 and argv
= 0 and no connect/removal functions. Excluding the data structures the
test program looks like this:

std::cout << “@1” << std::endl;
if((error = usbd_connect(&cparms, &connection))!=EOK) return 1;
std::cout << “@2” << std::endl;sleep(2);
if((error = usbd_disconnect(connection))!=EOK) return 1;
std::cout << “@3” << std::endl;sleep(2);
//Line 42 below
if((error = usbd_connect(&cparms, &connection))!=EOK) return 1;
std::cout << “@4” << std::endl;sleep(2);
if((error = usbd_disconnect(connection))!=EOK) return 1;

After printing “@3” the program generates a core dump. I haven’t found
any documentation that could explain this behaviour, could anyone please
explain what I’m doing wrong.


/Jonas Göransson

Jonas Göransson wrote:

I’ve ran into some problems using the usb library. I’m running the
devu-uhci driver. If I disconnect from the usb stack I can’t reconnect
without the library generating a SIGSEGV. The backtrace in DDD locks
like this
#3 0x080489c4 in main () at main.cpp:42
#2 0xb8205f3e in ?? () from libusbdi.so.2
#1 0xb8204db5 in ?? () from libusbdi.so.2
#0 0xb0317424 in ?? () from libc.so.2

The connection structures are the same as the one supplied in the
example in the usbd_connect documentation except that the 3Com stuff has
been replaced with USBD_CONNECT_WILDCARD and I supply argc = 0 and argv
= 0 and no connect/removal functions. Excluding the data structures the
test program looks like this:

std::cout << “@1” << std::endl;
if((error = usbd_connect(&cparms, &connection))!=EOK) return 1;
std::cout << “@2” << std::endl;sleep(2);
if((error = usbd_disconnect(connection))!=EOK) return 1;
std::cout << “@3” << std::endl;sleep(2);
//Line 42 below
if((error = usbd_connect(&cparms, &connection))!=EOK) return 1;
std::cout << “@4” << std::endl;sleep(2);
if((error = usbd_disconnect(connection))!=EOK) return 1;

After printing “@3” the program generates a core dump. I haven’t found
any documentation that could explain this behaviour, could anyone please
explain what I’m doing wrong.


/Jonas Göransson

I forgot

The devu-uhci ‘-V’ version string is
USB (UHCI), v1.10, v1.01, MAY 2 2002 running on Momentics NC

“Jonas Göransson” <jongo728@student.liu.se> wrote in message
news:as4pmn$d7s$1@inn.qnx.com

I’ve ran into some problems using the usb library. I’m running the
devu-uhci driver. If I disconnect from the usb stack I can’t reconnect
without the library generating a SIGSEGV. The backtrace in DDD locks
like this
#3 0x080489c4 in main () at main.cpp:42
#2 0xb8205f3e in ?? () from libusbdi.so.2
#1 0xb8204db5 in ?? () from libusbdi.so.2
#0 0xb0317424 in ?? () from libc.so.2

The connection structures are the same as the one supplied in the
example in the usbd_connect documentation except that the 3Com stuff has
been replaced with USBD_CONNECT_WILDCARD and I supply argc = 0 and argv
= 0 and no connect/removal functions. Excluding the data structures the
test program looks like this:

std::cout << “@1” << std::endl;
if((error = usbd_connect(&cparms, &connection))!=EOK) return 1;
std::cout << “@2” << std::endl;sleep(2);
if((error = usbd_disconnect(connection))!=EOK) return 1;

Just a suggestion, try resetting cparams and connection?

std::cout << “@3” << std::endl;sleep(2);
//Line 42 below
if((error = usbd_connect(&cparms, &connection))!=EOK) return 1;
std::cout << “@4” << std::endl;sleep(2);
if((error = usbd_disconnect(connection))!=EOK) return 1;

After printing “@3” the program generates a core dump. I haven’t found
any documentation that could explain this behaviour, could anyone please
explain what I’m doing wrong.


/Jonas Göransson

Just a suggestion, try resetting cparams and connection?

Even if use a complete new set of structures the result is still the same.

usbd_connect(&cparms, &connection)
usbd_disconnect(connection)
usbd_connect(&cparms2, &connection2)
usbd_disconnect(connection2)

Causes a Memory fault.
But if I do

usbd_connect(&cparms, &connection)
usbd_connect(&cparms2, &connection2)
usbd_disconnect(connection2)
usbd_disconnect(connection)

It doesn’t crash or report any errors (The above code has been stripped
of return value check etc).

/Jonas