flightaware / dump978

FlightAware's 978MHz UAT demodulator
BSD 2-Clause "Simplified" License
40 stars 16 forks source link

dump978-fa Ver 7.2 Segmentation fault on Ubuntu 20.04.4 #17

Open Derek-K opened 1 year ago

Derek-K commented 1 year ago
$sudo systemctl status dump978-fa
● dump978-fa.service - dump978 ADS-B UAT receiver
     Loaded: loaded (/lib/systemd/system/dump978-fa.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: core-dump) since Fri 2022-08-12 17:11:36 EDT; 5s ago
       Docs: https://flightaware.com/adsb/piaware/
    Process: 5166 ExecStart=/usr/share/dump978-fa/start-dump978-fa (code=dumped, signal=SEGV)
   Main PID: 5166 (code=dumped, signal=SEGV)
$ dump978-fa --version
dump978-fa 7.2
$ cat dump978-fa 
# dump978-fa configuration
# This is sourced by /usr/share/dump978-fa/start-dump978-fa as a
# shellscript fragment.

# If you are using a PiAware sdcard image, this config file is regenerated
# on boot based on the contents of piaware-config.txt; any changes made to this
# file will be lost.

# dump978-fa won't automatically start unless ENABLED=yes
ENABLED=yes

RECEIVER_OPTIONS="--sdr driver=rtlsdr --format CS8"
DECODER_OPTIONS=""
NET_OPTIONS="--raw-port 30978 --json-port 30979"
$ sudo dump978-fa --sdr driver=rtlsdr --format CS8 --raw-port 30978 --json-port 30979
raw-port: listening for connections on 0.0.0.0:30978
raw-port: listening for connections on [::]:30978
json-port: listening for connections on 0.0.0.0:30979
json-port: listening for connections on [::]:30979
Found Elonics E4000 tuner
Found Elonics E4000 tuner
Segmentation fault
$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

dump978-fa is compiled from GitHub source (without error). The same computer/SDR stick works fine with dump1090-fa without problems.

Additional debugging, SegFault happens at soapy_source.cc line 166 when setting the Sample Rate to 2083333.0 device_->setSampleRate(SOAPY_SDR_RX, 0, 2083333.0);

However, rtl_test was able to set sample rate at 2083333.0...

$ sudo rtl_test -s 2083333.0
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 

Using device 0: Generic RTL2832U OEM
Found Elonics E4000 tuner
Supported gain values (14): -1.0 1.5 4.0 6.5 9.0 11.5 14.0 16.5 19.0 21.5 24.0 29.0 34.0 42.0 
Exact sample rate is: 2083333.135571 Hz
Sampling at 2083333 S/s.

Info: This tool will continuously read from the device, and report if
samples get lost. If you observe no further output, everything is fine.

Reading samples in async mode...
Derek-K commented 1 year ago

Additional info...

apt list --installed | grep -i soapy

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libsoapysdr-dev/focal,now 0.7.2-1 amd64 [installed]
libsoapysdr0.7/focal,now 0.7.2-1 amd64 [installed,automatic]
soapyosmo-common0.7/focal,now 0.2.5-3build2 amd64 [installed,auto-removable]
soapysdr-module-rtlsdr/focal,now 0.3.0-2build1 amd64 [installed]
soapysdr0.7-module-rtlsdr/focal,now 0.3.0-2build1 amd64 [installed,automatic]
Derek-K commented 1 year ago

Found a few more lines that will cause Seg Fault in soapy_source.cc

Line 168

device_->setBandwidth(SOAPY_SDR_RX, 0, 3.0e6);

Line 179-180

device_->setGainMode(SOAPY_SDR_RX, 0, false);
device_->setGain(SOAPY_SDR_RX, 0, gain);
mutability commented 1 year ago

I don't get a crash on 20.04.4 (x86_64) with the same soapysdr package versions and a R820T2 dongle:

$ ./dump978-fa --sdr driver=rtlsdr --format CS8 --raw-port 30978 --json-port 30979
raw-port: listening for connections on 0.0.0.0:30978
raw-port: listening for connections on [::]:30978
json-port: listening for connections on 0.0.0.0:30979
json-port: listening for connections on [::]:30979
Found Rafael Micro R820T tuner
Found Rafael Micro R820T tuner
Exact sample rate is: 2083333.135571 Hz
[R82XX] PLL not locked!
SoapySDR: using maximum manual gain 49.6 dB
SoapySDR: using stream setting buffsize=262144
Allocating 15 zero-copy buffers

so this might be something specific to soapysdr with an e4k tuner.

Do you have a stacktrace for the segfault? I don't have e4k hardware to test with.

(unrelated, but you got lucky if your e4k works with dump1090 -- usually those tuners are quite deaf at 1090MHz)

Derek-K commented 1 year ago

FYI, I was able to run the 'older' dump978(mutability) successfully with the same hardware. Just wondering if I can use that to feed FA using skyaware978.

mutability commented 1 year ago

This isn't trivial to do (and the old dump978 has some reception bugs). Better to track down the segfault ..

mutability commented 1 year ago

Can you check if your soapysdr-rtlsdr driver is basically functional with SoapySDRUtil? (Install package soapysdr-tools if not already there). Should look something like this:

$ SoapySDRUtil --args='driver=rtlsdr' --rate=2400000 --direction=rx 
######################################################
##     Soapy SDR -- the SDR abstraction library     ##
######################################################

Found Rafael Micro R820T tuner
Found Rafael Micro R820T tuner
[R82XX] PLL not locked!
[INFO] Using format CS8.
Stream format: CS8
Num channels: 1
Element size: 2 bytes
Begin rx rate test at 2.4 Msps
Starting stream loop, press Ctrl+C to exit...
Allocating 15 zero-copy buffers
-^C
Derek-K commented 1 year ago

Yea, I have been trying to nail down the issue. SoapySDR is still pretty new to me, and I have been doing some readings and compiled a copy...

The problem is SoapySDR never picked up my E4000! I have seen postings that SoapySDR works with E4000 but never really figured out howto.

In fact, I had used this (old) E4000 since day one back when RTLSDR was started and was able to work well with dump1090 -> dump1090-mutability -> dump1090-fa without issue (but none of those require SoapySDR)

So, now the 'bug' is more towards SoapySDR (why it doesn't detect the E4000). But it is also interesting that dump978-fa WAS able to find my E4000 tuner before causing Seg Fault. :/

And for the record...

$ SoapySDRUtil --info
######################################################
##     Soapy SDR -- the SDR abstraction library     ##
######################################################

Lib Version: v0.8.1-g4e71a35e
API Version: v0.8.200
ABI Version: v0.8-2
Install root: /usr/local
Search path:  /usr/local/lib/SoapySDR/modules0.8-2
Module found: /usr/local/lib/SoapySDR/modules0.8-2/libremoteSupport.so (0.6.0-f7dca6e)
Available factories... remote
Available converters...
 -  CF32 -> [CF32, CS16, CS8, CU16, CU8]
 -  CS16 -> [CF32, CS16, CS8, CU16, CU8]
 -  CS32 -> [CS32]
 -   CS8 -> [CF32, CS16, CS8, CU16, CU8]
 -  CU16 -> [CF32, CS16, CS8]
 -   CU8 -> [CF32, CS16, CS8]
 -   F32 -> [F32, S16, S8, U16, U8]
 -   S16 -> [F32, S16, S8, U16, U8]
 -   S32 -> [S32]
 -    S8 -> [F32, S16, S8, U16, U8]
 -   U16 -> [F32, S16, S8]
 -    U8 -> [F32, S16, S8]
$ SoapySDRUtil --args='driver=rtlsdr' --rate=2400000 --direction=rx
######################################################
##     Soapy SDR -- the SDR abstraction library     ##
######################################################

Error in rate test: SoapySDR::Device::make() no match
$ SoapySDRUtil --find
######################################################
##     Soapy SDR -- the SDR abstraction library     ##
######################################################

No devices found! 
$ SoapySDRUtil --find="driver=rtlsdr"
######################################################
##     Soapy SDR -- the SDR abstraction library     ##
######################################################

No devices found! driver=rtlsdr
Derek-K commented 1 year ago

Oh dang... my bad.

Just realized my search path and library are all pointed to version 0.8 (The ones I build from source), but the modules (installed via apt) are all version 0.7 and stored somewhere else.

I can't seem to find the latest version (0.8) even after apt update. And still unsure where I can download the module source code and compile them myself...

Derek-K commented 1 year ago

OK, problem fixed... At least for the SoapySDR part.

$ SoapySDRUtil --info
######################################################
##     Soapy SDR -- the SDR abstraction library     ##
######################################################

Lib Version: v0.8.1-g4e71a35e
API Version: v0.8.200
ABI Version: v0.8-2
Install root: /usr/local
Search path:  /usr/local/lib/SoapySDR/modules0.8-2
Module found: /usr/local/lib/SoapySDR/modules0.8-2/libremoteSupport.so (0.6.0-f7dca6e)
Module found: /usr/local/lib/SoapySDR/modules0.8-2/librtlsdrSupport.so (0.3.3-40d0708)
Available factories... remote, rtlsdr
Available converters...
 -  CF32 -> [CF32, CS16, CS8, CU16, CU8]
 -  CS16 -> [CF32, CS16, CS8, CU16, CU8]
 -  CS32 -> [CS32]
 -   CS8 -> [CF32, CS16, CS8, CU16, CU8]
 -  CU16 -> [CF32, CS16, CS8]
 -   CU8 -> [CF32, CS16, CS8]
 -   F32 -> [F32, S16, S8, U16, U8]
 -   S16 -> [F32, S16, S8, U16, U8]
 -   S32 -> [S32]
 -    S8 -> [F32, S16, S8, U16, U8]
 -   U16 -> [F32, S16, S8]
 -    U8 -> [F32, S16, S8]
$ SoapySDRUtil --find
######################################################
##     Soapy SDR -- the SDR abstraction library     ##
######################################################

Found Elonics E4000 tuner
Found device 0
  driver = rtlsdr
  label = Generic RTL2832U OEM :: 
  manufacturer = Realtek
  product = RTL2838UHIDIR
  serial = 
  tuner = Elonics E4000

But still... Seg fault at setting sample rate.

$ ./dump978-fa --sdr driver=rtlsdr 
Found Elonics E4000 tuner
Found Elonics E4000 tuner
Segmentation fault (core dumped)

$ ./dump978-fa --version
dump978-fa 7.2
mutability commented 1 year ago

This sounds like you have version skew between the soapysdr/rtlsdr libraries and dump978.

please ensure that:

a) you have only one version of librtlsdr installed b) you have only one version of soapysdr/soapysdr-rtlsdr installed, and it was compiled against the librtlsdr in (a) c) you compiled dump978 against the soapysdr from (b)

Derek-K commented 1 year ago

OK, finally. Long story short.

I have removed all SoapySDR packages again, only left with the 8.0 binaries. When I try to build dump978-fa it failed initially because

dpkg-checkbuilddeps: error: Unmet build dependencies: libsoapysdr-dev
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)

So for the heck of it, I tried to follow the suggestion added "-d" and build with

sudo dpkg-buildpackage -b --pre-clean --no-sign -d

dump978-fa seems to work (at no more seg fault) at the moment, waiting to see if the first packet shows up...