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
SIGSEGV with memcpy() in rx_meter_c::work() (src/dsp/rx_meter.cpp:73) on FreeBSD #1275
Comments
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. |
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. |
Hello @argilo Thanks for your reply and investigation. Well, I'll try to investigate on the GNURadio side then ! Best regards, Ganael. |
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) :
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. |
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 ? |
This may be related to #1265. The fix also requires GNU Radio v3.10.7.0, which fixes a bug in buffer size limts. |
@martymac I did some more digging, and it appears the issue lies in GNU Radio. I used
GNU Radio requested that the second half of the double-mapped buffer be allocated at GNU Radio's Interestingly, one of the other double-mapped buffer implementations ( |
|
The crash in the simple flow graph when ASLR is enabled appears to have the same root cause; |
The order of precedence is
Linux seems to work with |
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. |
Closing, since the root cause was a bug in GNU Radio, which was fixed in gnuradio/gnuradio#6854. |
Thanks a lot for your help, Clayton! I'll give it a try and tell you how it goes :) |
Glad I could help. If you run into any trouble after applying the GNU Radio patch, let me know. |
Everything seems to be working fine with your patch :) Thanks again for your precious help! |
This patch is a backport of ca44241 from upstream: runtime: Use MAP_FIXED flag to ensure buffer halves are contiguous It fixes SIGSEGV observed with GNU Radio buffers consumers such as comms/gqrx. Discussed here: gqrx-sdr/gqrx#1275 gnuradio/gnuradio#6854 PR: 272543 Reported by: trasz Obtained from: GNU Radio team (GH pull request: 6854) MFH: 2023Q3
This patch is a backport of ca44241 from upstream: runtime: Use MAP_FIXED flag to ensure buffer halves are contiguous It fixes SIGSEGV observed with GNU Radio buffers consumers such as comms/gqrx. Discussed here: gqrx-sdr/gqrx#1275 gnuradio/gnuradio#6854 PR: 272543 Reported by: trasz Obtained from: GNU Radio team (GH pull request: 6854) MFH: 2023Q3 (cherry picked from commit 35f7383)
Hello,
Gqrx crashes on FreeBSD 13.2 (amd64, with Gnuradio 3.8.4). I get the following backtrace :
The problem occurs with an up-to-date master branch and is triggered with a rtl-sdr dongle when starting DSP with any of the 3 WFM modes.
It seems to be related to the use of GNU Radio buffers. I tried to use a fixed buffer size in src/dsp/rx_meter.cpp (inspired by commit 8d03fd1) and it fixed the problem.
I basically increased the number of items when calling gr::make_buffer() that way:
but the patch is obviously not clean at all and probably requires more changes.
Could you have a look at that, please ?
(the problem has originally been reported here: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=272543)
Thanks in advance,
Best regards,
Ganael.
The text was updated successfully, but these errors were encountered: