-
Notifications
You must be signed in to change notification settings - Fork 179
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
SoapySDR python stuck in loop after stopping sdrplay service #364
Comments
@Ifilehk - thanks for reporting the issue. When I replicate your experiment here, I too notice that my C program hangs, and when I inspect it with
Since the shared library Franco |
Hello Franco. Thank you for your fast reply. I am not that specialist in C/C++ but find it strange that there is no mechanism to avoid a deadlock. Imagine libsdrplay_api.so.3.07 would just crash, in that case it is impossible for the library to release the lock. So not sure that the external library should absolutely implement a mutex release because it would not cover the crash case. Tarik |
Tarik, I am not sure I understand your comment. As you can see from the gdb stack trace the mutex I am referring to is inside the SDRplay proprietary library Therefore in case of an abnormal termination of the client application (i.e. a crash; a library in itself doesn't crash but can definitely cause the client application to crash) there wouldn't be any mutex any more since the whole process is terminated. Franco |
Maybe we are not tuned on the right frequency yet :-) If the service sdrplay is stopped. The behavior of SoapySDR when calling Device_enumerate() it as expected. It throws the errors: I start the sdrplay service. Everything fine. Device_enumerate() detects the SDRPLAY device. I wonder now why, when I stop the sdrplay service, SoapySDR when calling Device_enumerate() again is not able to throw the errors: It seems for me to be in the same situation as at the start of this test that works as expected. We should have an "sdrplay_api_Open() Error" and we should not be able to call sdrplay_api_LockDeviceApi(). What is wrong my seeing ? Tarik |
Tarik, If you want to reinitialize the SDRplay API every single time, you can use a Python script like this:
Franco |
Franco,
Thank you for your support so far ! Tarik |
Franco, |
Tarik, As per your question about the reason of the way I am invoking One of the issues of writing a general purpose module like SoapySDRPlay3 is that it is almost impossible to foresee all the possible ways it could be used since at the end of the day it is just a shared library/module; for instance one could imagine a different use case where the client application is successfully attached to an RSP (possibly streaming from it), and while it is attached it calls the In these cases my personal preference is to what I call the 'principle of least surprise', where the user running the application wouldn't be 'surprised' by with streaming from the RSP going down while they are trying to list the available devices. Also I find that making function calls explicit in the script, like All in all I think your approach of calling Franco |
The following situation is causing a hang with python running at 100% CPU, so most probably SoapySDR with SoapySDRPlay3 stuck in loop. Thank you for checking and resolving.
Python script:
import SoapySDR, time
while 1:
devices = SoapySDR.Device_enumerate()
time.sleep(1)
in a console:
service sdrplay start --> reaction OK. SDRplay device found
service sdrplay stop --> reaction BAD. The script crashes.
gdb trace:
__futex_abstimed_wait_common64 (private=128, cancel=true, abstime=0x0, op=265, expected=12262, futex_word=0x7ffff63ff910) at ./nptl/futex-internal.c:57
57 ./nptl/futex-internal.c: No such file or directory.
(gdb) bt
#0 __futex_abstimed_wait_common64 (private=128, cancel=true, abstime=0x0, op=265, expected=12262, futex_word=0x7ffff63ff910) at ./nptl/futex-internal.c:57
#1 __futex_abstimed_wait_common (cancel=true, private=128, abstime=0x0, clockid=0, expected=12262, futex_word=0x7ffff63ff910) at ./nptl/futex-internal.c:87
#2 __GI___futex_abstimed_wait_cancelable64 (futex_word=futex_word@entry=0x7ffff63ff910, expected=12262, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=private@entry=128)
at ./nptl/futex-internal.c:139
#3 0x00007ffff7ccc6a4 in __pthread_clockjoin_ex (threadid=140737324774976, thread_return=0x0, clockid=0, abstime=0x0, block=) at ./nptl/pthread_join_common.c:105
#4 0x00007ffff68bd337 in std::thread::join() () from /lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ffff7ccff68 in __pthread_once_slow (once_control=0x555555cf7138, init_routine=0x7ffff68bbdc0 <__once_proxy>) at ./nptl/pthread_once.c:116
#6 0x00007ffff70129da in std::__future_base::_Async_state_commonV2::_M_complete_async() () from /usr/local/lib/libSoapySDR.so.0.8-2
#7 0x00007ffff7010411 in SoapySDR::Device::enumerate(std::map<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::less<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits, std::allocator > const, std::__cxx11::basic_string<char, std::char_traits, std::allocator > > > > const&) () from /usr/local/lib/libSoapySDR.so.0.8-2
#8 0x00007ffff714931a in _wrap_Device_enumerate () from /usr/local/lib/python3.10/dist-packages/_SoapySDR.so
#9 0x00005555556af138 in cfunction_call (func=<built-in method Device_enumerate of module object at remote 0x7ffff73ada30>, args=, kwargs=) at ../Objects/methodobject.c:552
#10 0x00005555556bdc3b in _PyObject_Call (kwargs=, args=(), callable=<built-in method Device_enumerate of module object at remote 0x7ffff73ada30>, tstate=0x555555b5a420)
at ../Objects/call.c:305
The text was updated successfully, but these errors were encountered: