Problem With LibUSB 1.0-0-dev on Ubuntu 14.0.4 and Intel Nuc

C, C++, and Visual C++
jrobe
Fresh meat
Posts: 2
Joined: Tue Nov 04, 2014 11:45 pm
Contact:

Problem With LibUSB 1.0-0-dev on Ubuntu 14.0.4 and Intel Nuc

Postby jrobe » Sat Apr 30, 2016 9:50 pm

Hello!

I'm currently making a robot using Phidgets and an onboard Intel Nuc and ROS.

I'm running into a really weird segfault issue that's originating from (after hours of testing/bugfinding/rewriting code) libusb. I finally stumbled upon CPhidget_enableLogging(PHIDGET_LOG_INFO, NULL);
That enabled me to see the libusb errors that happen non-deterministically, and (sometimes) cause my program to segfault.
This is an example where the program would segfault.

Code: Select all

int error = CPhidgetMotorControl_create(&(motors[i].control));
if(error != EPHIDGET_OK)
{
   ROS_ERROR_STREAM("Phidget error: " << error << " when creating motor controller.");
}
   
CPhidget_set_OnAttach_Handler((CPhidgetHandle) motors[i].control, AttachHandler, NULL);
CPhidget_enableLogging(PHIDGET_LOG_INFO, NULL);
error = CPhidget_open((CPhidgetHandle) motors[i].control, motors[i].serial);
if(error != EPHIDGET_OK)
{
   ROS_ERROR_STREAM("Phidget error: " << error << " when opening motor controller.");
}
int result;
// Wait up to 10000 ms for a device to be plugged in
if((result = CPhidget_waitForAttachment((CPhidgetHandle) motors[i].control, 10000))){
   ROS_ERROR_STREAM("Phidget error: " << error << " when attempting to open motor controller.");
}
ROS_INFO("Got Here: %i", motors[i].serial);


Log:
INFO: Enabling logging
INFO: Initializing libusb
INFO: New device in CUSBBuildList: 2/16
INFO: New device in CUSBBuildList: 2/15
INFO: New device in CUSBBuildList: 2/14
ERR: Unexpected error converting string to UTF-8: Invalid argument.
INFO: New device in CUSBBuildList: 2/13
INFO: New device in CUSBBuildList: 2/12
INFO: New device in CUSBBuildList: 2/10
ERR: Unexpected error converting string to UTF-8: Invalid argument.
INFO: New device in CUSBBuildList: 2/9
INFO: New device in CUSBBuildList: 2/8
INFO: New device in CUSBBuildList: 2/7
INFO: New device in CUSBBuildList: 2/6
INFO: New device in CUSBBuildList: 2/5
INFO: Using Control Endpoint for Host->Device communication.
INFO: WriteThread running
[ INFO] [1462074018.351383333]: New Device Attached
INFO: ReadThread running
[ INFO] [1462074018.360556966]: Got Here: 395285
INFO: Enabling logging
ERR: libusb_get_string_descriptor_ascii failed with error code: -1
WARN: unable to open active device: 1
ERR: libusb_get_string_descriptor_ascii failed with error code: -1
*** Error in `/home/urmp/robotic-mining/urmpspace/devel/lib/astro/simple_drive': double free or corruption (top): 0x00000000011b95d0 ***
Aborted (core dumped)


Like I said above, this happens sometimes at startup (I'm assuming when calling CPhidget_open); and when it doesn't happen the program will run forever without a crash; another strange thing is that it happens only when I'm using my Intel Nuc to program. If I use any other laptops running the same OS, or virtualized in Parallels this doesn't happen.

There are also a couple other types of errors, shown below; and also, occasionally an error will be shown, but the program doesn't segfault.

Any help would be extremely appreciated. The NASA competition this robot is going to starts in two weeks!

Other Error Logs:
1 (No Segfault, and works after this point):
INFO: Enabling logging
[ERROR] [1462074455.255049030]: Phidget error: 12 when opening motor controller.
WARN: Failure in CUSBReadPacket - Report Length: 0, bytes read: 25. Probably trying to use too many Phidgets at once, and some data is being lost.
INFO: ReadThread exiting normally (Phidget detached)
INFO: WriteThread exiting normally (Phidget detached)
INFO: Using Control Endpoint for Host->Device communication.
INFO: WriteThread running


2 (Segfaulted):
urmp@urmp-robot:~/robotic-mining/urmpspace/src/astro$ rosrun astro simple_drive INFO: Enabling logging
INFO: Initializing libusb
INFO: New device in CUSBBuildList: 2/16
INFO: New device in CUSBBuildList: 2/15
INFO: New device in CUSBBuildList: 2/14
INFO: New device in CUSBBuildList: 2/13
ERR: Unexpected error converting string to UTF-8: Invalid argument.
INFO: New device in CUSBBuildList: 2/12
INFO: New device in CUSBBuildList: 2/10
INFO: New device in CUSBBuildList: 2/9
INFO: New device in CUSBBuildList: 2/8
INFO: New device in CUSBBuildList: 2/7
INFO: New device in CUSBBuildList: 2/6
INFO: New device in CUSBBuildList: 2/5
ERR: libusb_get_string_descriptor_ascii failed with error code: -1
INFO: Using Control Endpoint for Host->Device communication.
ERR: Unexpected error converting string to UTF-8: Invalid argument.
ERR: CUSBGetDeviceCapabilities returned nonzero code: 3
INFO: WriteThread running
[ INFO] [1462074504.815540327]: New Device Attached
Segmentation fault (core dumped)


3: Segfault
INFO: Enabling logging
INFO: Initializing libusb
INFO: New device in CUSBBuildList: 2/16
INFO: New device in CUSBBuildList: 2/15
INFO: New device in CUSBBuildList: 2/14
INFO: New device in CUSBBuildList: 2/13
INFO: New device in CUSBBuildList: 2/12
INFO: New device in CUSBBuildList: 2/10
INFO: New device in CUSBBuildList: 2/9
INFO: New device in CUSBBuildList: 2/8
INFO: New device in CUSBBuildList: 2/7
INFO: New device in CUSBBuildList: 2/6
ERR: libusb_get_string_descriptor_ascii failed with error code: -1
ERR: libusb_get_string_descriptor_ascii failed with error code: -1
ERR: libusb_get_string_descriptor_ascii failed with error code: -1
*** Error in `/home/urmp/robotic-mining/urmpspace/devel/lib/astro/simple_drive': double free or corruption (!prev): 0x0000000000845840 ***
Aborted (core dumped)


Another note: If you need me to launch it in GDB I can give you the backtrace... But it happens in a different thread so I can't get the original line in my code that it happened. Just let me know!

porzoo
Phidgetsian
Posts: 5
Joined: Tue Jun 21, 2016 11:22 pm
Contact:

Re: Problem With LibUSB 1.0-0-dev on Ubuntu 14.0.4 and Intel

Postby porzoo » Tue Jun 21, 2016 11:26 pm

Hey,
I have the same Problem as you. I also use an Intel NUC with ROS installed. Everytime I launch my Motor Node, it shows the same behaviour as you described. Did you find a solution for this problem already?

Best regards

jrobe
Fresh meat
Posts: 2
Joined: Tue Nov 04, 2014 11:45 pm
Contact:

Re: Problem With LibUSB 1.0-0-dev on Ubuntu 14.0.4 and Intel

Postby jrobe » Wed Jun 22, 2016 8:54 am

Hey,

Good to hear that it's not just me! But I have unfortunate news, that I wasn't able to fix the problem. It still happens no matter what I do.

ROS does have a sort of bandaid for the problem though, which worked well enough for the competition. In the launch file for your node, if you set Respawn=true, then the restart would happen fast enough on a crash that it was pretty much unnoticeable.

More on that here http://wiki.ros.org/roslaunch/XML/node

Sorry that that's the only thing I could find :( if you have more information or fix it please let me know!!

porzoo
Phidgetsian
Posts: 5
Joined: Tue Jun 21, 2016 11:22 pm
Contact:

Re: Problem With LibUSB 1.0-0-dev on Ubuntu 14.0.4 and Intel

Postby porzoo » Wed Jun 22, 2016 8:05 pm

Hey,
a big thanks for your advice, you saved me a lot of time! If I find another solution, I will write it down here.

Greetings


Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 0 guests