kevinmehall / rust-soapysdr

Rust bindings for SoapySDR, the vendor-neutral software defined radio hardware abstraction layer
Apache License 2.0
75 stars 22 forks source link

Rare STATUS_ACCESS_VIOLATION (Segfault) when calling soapysdr::enumerate("") #26

Closed porkiedev closed 1 year ago

porkiedev commented 1 year ago

I'm brand new to Rust and have only been working with it for a little over a week. Given that this crate is simply a wrapper of SoapySDR itself, this may be more suited towards the SoapySDR repo, but I'm sending it here first, just in case.

I have an egui-based GUI application that functions as an SDR interface. I have a button that calls a function that essentially leads to the soapysdr::enumerate("") function. This button has worked without fail probably over 100 times now, but it just completely crashed my application with an error that seems to indicate a Segmentation Fault. This is why I suspect the SoapySDR library is the underlying issue, but I have no idea what to say. I'm not sure that I can reproduce the issue. Hopefully, somebody has an idea of how this should be handled. There is no unsafe code in my application. Here are some screenshots of the console output from my program along with the function that was called when the program crashed.

EDIT: This is on Windows 10 using the latest stable binary installer for PothosSDR.

image image

kevinmehall commented 1 year ago

This is most likely in one of the SoapySDR modules (e.g https://github.com/pothosware/SoapySDRPlay3) or even the underlying device-specific library. Quality of these is highly variable and they're written in C++.

See the warning on the readme of this repo:

Many SoapySDR driver modules have error handling and thread safety bugs. This library provides safe Rust wrappers assuming the drivers meet the (under-documented) intentions of the SoapySDR core API contract, but if SoapySDR loads modules that violate this contract and you do atypical things with them, you may encounter unexpected behavior. For details, see https://github.com/pothosware/SoapySDR/issues/111.

porkiedev commented 1 year ago

I am guessing you're right. I'll tolerate the problem for now and look into the issue in the future. I will have to test each SoapySDR module one-by-one until I find the problem.

Thanks a lot :)