Comments (16)
Thanks a lot for your help, Clayton! I'll give it a try and tell you how it goes :)
from gqrx.
Hi there,
I can't reproduce this on Linux or MacOS. The buffer size calculations look correct, and I'm starting to suspect there could be an issue with GNU Radio's double-mapped buffers on FreeBSD.
from gqrx.
I installed GNU Radio on FreeBSD and immediately ran into a similar segfault when attempting to run a simple flow graph (Noise Source --> Throttle --> Null Sink). So it would seem that the issue lies in GNU Radio or FreeBSD's GNU Radio package, rather then Gqrx.
from gqrx.
Hello @argilo
Thanks for your reply and investigation. Well, I'll try to investigate on the GNURadio side then !
Best regards,
Ganael.
from gqrx.
Hello,
I could reproduce the immediate crash you are observing, it is related to ASLR. Gnuradio seems to have problems when it is enabled. If you disable it globally with (before running Gr flow's python code) :
# sysctl kern.elf64.aslr.enable=0
your simple flow graph (Noise Source --> Throttle --> Null Sink) will not crash anymore.
Actually, I had to disable ASLR for Gqrx to make it work again when ASLR has been turned on by default on FreeBSD, see:
https://cgit.freebsd.org/ports/commit/?id=f05f6dcedb5dad5b7b515ebede9bf6a58de1d46c
so Gqrx' crash I am writing about here is not related as what you are observing happens with ASLR disabled.
The backtrace above clearly shows an access to an invalid write pointer during memcpy() (see: /usr/ports/comms/gqrx/work/gqrx-2.16/src/dsp/rx_meter.cpp:73) that triggers SIGSEGV.
What I don't know is if it is due to a bug in Gqrx code or in Gnuradio buffers handling on FreeBSD :/
If you want to reproduce the issue on FreeBSD and need help, do not hesitate to contact me, I'll help you setting things up.
Best regards,
Ganael.
from gqrx.
An interesting thing: if I start Gqrx with WFM preselected and just turn DSP on, it does not crash. Problems arise when changing DSP mode (e.g. AM -> WFM x). Could there be a problem with de-allocation/re-allocation of Gr buffers when switching mode ?
from gqrx.
This may be related to #1265. The fix also requires GNU Radio v3.10.7.0, which fixes a bug in buffer size limts.
from gqrx.
Hello Jeff,
Thanks for your feedback.
This does not appear to be the same symptom as in #1233 (fixed by PR #1265): the DSP does not hang, but Gqrx crashes with SIGSEGV.
Unfortunately, the same bug still occurs with Gnuradio 3.10.7.0 and latest master (d7219a6) from Gqrx.
from gqrx.
@martymac I did some more digging, and it appears the issue lies in GNU Radio. I used truss
to monitor allocation of GNU Radio's double-mapped buffers, and it can be seen that the buffer that causes a segfault in Gqrx is not contiguous:
getpid() = 1230 (0x4ce)
shm_open2("/gnuradio-1230-20",O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC,0600,0,"(null)") = 21 (0x15)
ftruncate(21,0x408000) = 0 (0x0)
mmap(0x0,4227072,PROT_READ|PROT_WRITE,MAP_SHARED,21,0x0) = 34758197248 (0x817c00000)
munmap(0x817e04000,2113536) = 0 (0x0)
mmap(0x817e04000,2113536,PROT_READ|PROT_WRITE,MAP_SHARED,21,0x0) = 34762391552 (0x818000000)
close(21) = 0 (0x0)
shm_unlink("/gnuradio-1230-20") = 0 (0x0)
GNU Radio requested that the second half of the double-mapped buffer be allocated at 0x817e04000
(immediately after the first half), but the kernel did not accept this hint and instead allocated it at 0x818000000
. Gqrx segfaults as soon as it attempts to write beyond the end of the first half of the double-mapped buffer.
GNU Radio's vmcircbuf_mmap_shm_open::vmcircbuf_mmap_shm_open
constructor does not check for discontiguity:
Interestingly, one of the other double-mapped buffer implementations (vmcircbuf_mmap_tmpfile::vmcircbuf_mmap_tmpfile
) does have a contiguity check, although it simply raises a std::runtime_error
if the allocation was discontiguous:
from gqrx.
mmap
has a MAP_FIXED
flag which indicates that the exact addr
value must be used. Perhaps GNU Radio should be using that.
from gqrx.
The crash in the simple flow graph when ASLR is enabled appears to have the same root cause; truss
shows that a discontiguous double-mapped buffer is allocated in that case as well.
from gqrx.
The order of precedence is
- vmcircbuf_createfilemapping
- vmcircbuf_sysv_shm
- vmcircbuf_mmap_shm
- vmcircbuf_mmap_tmpfile
Linux seems to work with sysv
and createfilemapping
is for windows, so the mmap
versions probably don't get tested much. I take it FreeBSD doesn't have sysv
IPC?
from gqrx.
I opened a pull request, which I hope will fix this: gnuradio/gnuradio#6854
@martymac Would you be able to take this for a spin on FreeBSD? I expect that things should work correctly even when ALSR is enabled.
from gqrx.
Closing, since the root cause was a bug in GNU Radio, which was fixed in gnuradio/gnuradio#6854.
from gqrx.
Glad I could help.
If you run into any trouble after applying the GNU Radio patch, let me know.
from gqrx.
Everything seems to be working fine with your patch :) Thanks again for your precious help!
from gqrx.
Related Issues (20)
- Settings stored as QComboBox indexes
- Plotter does not redraw if "Z" pressed while DSP is stopped HOT 1
- Program falsely detects crash after reboot as well as SIGHUP/SIGKILL/SIGTERM. HOT 5
- Detaching kernel driver on startup fails HOT 2
- Y axis labels don't fit in saved waterfall
- Build fails since last commit HOT 3
- Funcube Dongle Pro+ with GQRX
- Idea / Feature: better SoapySDR Support ? HOT 1
- Trouble compiling gqrx on Ubuntu 20.04 using three different versions HOT 8
- Hide tags on start-up. HOT 2
- Add support for the RTL-SDR Blog V4 to AppImage and dmg packages HOT 4
- gqrx: error while loading shared libraries: libgnuradio-blocks.so.3.10.5: cannot open shared object file: No such file or directory HOT 1
- Request: create a gqrx-sdr Flatpak HOT 1
- Unknown remote command: ("\\get_powerstat") , when connecting from hamlib (rigctl) or wsjtx HOT 4
- Release version 2.17 HOT 7
- Minor issues in the new plotter HOT 1
- Frequency axis in saved waterfall is incorrect HOT 1
- Replace integer screen coordinates with qreal
- Represent frequencies as double
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gqrx.