Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash while unplugging a connected usb device #803

Open
Elgot opened this issue Oct 26, 2024 · 0 comments
Open

Crash while unplugging a connected usb device #803

Elgot opened this issue Oct 26, 2024 · 0 comments

Comments

@Elgot
Copy link

Elgot commented Oct 26, 2024

Issue Description

I would like my application to allow usb usrp devices to be added or removed by the user at runtime. This seems to work, but if I have an active multi_uspr connection the application crashes when the shared_ptr of an unplugged device goes out of scope. (A workaround is to keep a list of invalid pointers...).

Setup Details

Host OS: Ubuntu 22.04
UHD: UHD_4.6.0.0-3-g080b1baa
Hardware: USRP B205mini

Expected Behavior

The application should continue to run.

Actual Behaviour

The application crashes with this message:

terminate called after throwing an instance of 'uhd::usb_error'
  what():  RuntimeError: USBError -4: usb tx4 submit failed: LIBUSB_ERROR_CODE -4

Steps to reproduce the problem

Just create a multi_usrp connection, unplug the hardware and let the pointer go out of scope.

#include <iostream>
#include <uhd/usrp/multi_usrp.hpp>

int main()
{
    
     uhd::usrp::multi_usrp::sptr dev = uhd::usrp::multi_usrp::make("");
     std::cout << "Unplug the device and press enter\n";
     std::getchar();
     dev = nullptr;
     std::cout << "Press enter\n";
     std::getchar();
     
     return 0;
}

If you don't unplug the device destructing the pointer does not cause a crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant