stop() tore the sample thread down with stopWork() + delete and only then
cleared m_deviceShared.m_thread. The buddy's applySettings() suspends and
resumes that thread through m_thread from another thread, without holding
this device's mutex, so it could restart the thread between stopWork() and
delete (QThread: Destroyed while thread is still running -> qFatal/abort),
or call through the pointer after the delete. The device's own
applySettings() had the same exposure on its own thread pointer, since it
does not take m_mutex either.
Seen when the Satellite Tracker loads presets into the Rx and Tx device
sets of one Pluto at AOS: abort in PlutoSDRInputThread::~PlutoSDRInputThread
<- PlutoSDRInput::stop <- DSPDeviceSourceEngine::gotoIdle.
Add DevicePlutoSDRShared::m_threadsMutex (recursive, shared by all PlutoSDR
device sets) and take it in start() around startWork()/publish, in stop()
and handleError() around unpublish + teardown (unpublishing first), in
suspendBuddies()/resumeBuddies(), and for the whole suspend -> apply ->
resume sequence in applySettings(). Also wait() before deleting the thread
and check the own-thread pointer before resuming it.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Both PlutoSDRInput::applySettings() and PlutoSDROutput::applySettings()
suspend their buddies' threads and resume them later:
if (buddySharedPtr && buddySharedPtr->m_threadWasRunning) {
buddySharedPtr->m_thread->startWork(); // m_thread may be null
The suspend half tests buddySharedPtr->m_thread and sets
m_threadWasRunning from it, but m_threadWasRunning is sticky state on the
buddy's shared struct: between suspend and resume the buddy's thread can
be destroyed -- its device was stopped, or a preset was loaded into it,
both of which null m_thread -- while m_threadWasRunning stays true.
startWork() is then called on a null pointer.
Seen on macOS with the Satellite Tracker, which loads a preset into the
Rx and the Tx device set of the same Pluto at AOS: the Tx applySettings
is between suspend and resume when the Rx side is rebuilt.
PlutoSDROutput::applySettings + 7284
PlutoSDROutput::handleMessage
DeviceSampleSink::handleInputMessages
MessageQueue::push
PlutoSDROutput::deserialize
DeviceAPI::loadSamplingDeviceSettings
DeviceUISet::loadDeviceSetSettings
Disassembly confirms the faulting load is m_thread's vtable read with
x0 = 0. Test m_thread, as the suspend half does.
PlutoSDRInput::start() guards both m_deviceShared.m_deviceParams and
m_deviceShared.m_deviceParams->getBox(); PlutoSDROutput::start() only
guards getBox() and dereferences m_deviceParams to get there.
m_deviceParams is null when the device never opened (no route to the
iio host, radio rebooting, or -- on macOS -- the Local Network privacy
grant denied, which is silent), and closeDevice() also sets it to 0.
Pressing Start on such a device set then dereferences null and crashes
the application. Mirror the Input side's check.
Add a terminating LF to tracked text files that were missing a
newline at end of file. This avoids Codacy whitespace failures and
ensures text files conform to the repository line-ending policy.
Affected files were identified and fixed with the following script.
It checks all tracked files against .gitattributes, skips files marked
as binary or -text, and reports the final 32 bytes of any non-empty text
file that does not end with LF before adding the missing newline.
git ls-files -z |
while IFS= read -r -d '' f; do
attr=$(git check-attr text -- "$f")
case "$attr" in
"$f: text: unset"|"$f: text: unspecified")
continue
;;
esac
[ -f "$f" ] || continue
[ -s "$f" ] || continue
[ "$(tail -c 1 -- "$f" | od -An -t x1 | tr -d ' \n')" = "0a" ] || {
printf '%s\n' "$f"
tail -c 32 -- "$f" | hexdump -C
printf '\n' >> "$f"
}
done
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Normalize existing text files to LF to conform to the repository-wide
line-ending policy defined by .gitattributes by:
git add --renormalize .
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Assign descriptive names to SDRangel threads so thread activity can be
identified when investigating multi-threaded behavior, including crashes,
leaks, and synchronization issues in debuggers and others tools.
Use compact names to fit platform thread-name limits (14 chars) while
retaining the component and thread role where possible.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
MessageQueue::pop() transfers ownership of the popped message to the
caller, but many handleInputMessages() implementations only deleted
the message when handleMessage() returned true. When a message was not
handled, ownership had already been transferred from the queue and the
message was leaked.
This was identified while investigating an ASAN leak in the audio
subsystem.
Update the applicable handleInputMessages() implementations to always
delete messages after handleMessage() returns. Unhandled messages are
also logged with the component and message identifier so unexpected
message routing is visible during debugging.
This change:
- Ensures every message popped from a queue has its ownership resolved.
- Prevents leaks when handleMessage() returns false.
- Makes unhandled messages visible instead of silently discarding them.
- Preserves the existing message handling logic and does not require
components to handle message types that are legitimately irrelevant
to them.
The changes are intentionally mechanical and limited to the common
message queue ownership and diagnostic pattern.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Detection aligns on uncorrected preamble bins. If the aligned, fractional-CFO-corrected upchirp peak retains a one-bin integer residual, adjust the next FIFO consumption by -osFactor * residual. The current Sync window has already been read; remaining net-ID windows, downchirps and payload use the adjusted grid.
In separate live runs, 25.8% of fix-off frames had a residual and 93.8% of those needed binfix recovery; with the fix enabled, 8.2% had a residual and 100% of those passed without binfix. The runs were not paired, so they support the mechanism but do not measure a success-rate improvement.
Add a pending sample adjustment to the next FIFO consumption and clear it after use or frame reset. Nothing sets a nonzero adjustment yet, so decoding behavior is unchanged.
Keep the existing fractional STO result exactly, including half-bin ties. When requested through an optional out-parameter, report the integer residual of the aligned, fractional-CFO-corrected preamble peak. Existing callers do not request the residual, so decoding behavior is unchanged.
get_spectrum_history reports what has been on a band over the last
while from the spectrum's scroll history, per bin and as a list of
signals with their duty cycles; get_waterfall_image returns the same
history as a picture, the first tool to put image content beside the
text in a result. Both switch scrolling on when it is off and say so.
list_windows shows every window with its workspace and whether it is
hidden, and set_workspace takes hidden alongside the workspace index.
capture_audio's inline copy is now mono and decimated to 16 kHz, so a
ten second capture fits under the 1 MB result limit; the file on disk
is unchanged.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Both overrode showEvent for the QTBUG-100333 redraw workaround without
calling the base class, so the window state FeatureGUI publishes on show
never ran and the windows API reported the windows hidden while they
were on screen.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The display was scaled for the gain the device had, and a change of tens of decibels left the
trace off the top or along the bottom. After the chosen gain has reached the trace the main
spectrum's reference level and range are set from it, as the GUI's autoscale button does; the
autoscale argument, default true, leaves the display alone when false, and the reply says
whether it was done. The auto tune in listen and scan does the same and says so.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The guard that removes a device set a failed listen or scan created compared only the index,
so a set another request had replaced at that index would have gone instead. The engine's UID
and the object's address are recorded at creation and checked before removal.
The Codex config writer now recognises sdrangel.url = "..." under [mcp_servers] as the server
already being defined, and refuses rather than adding a [mcp_servers.sdrangel] table a TOML
parser would reject as defined twice.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Tools: listen and scan reclaim their earlier channels before retuning the device, so a scanner
left running cannot move it in between; scan counts a range before building it; booleans are
read from JSON booleans, numbers and strings alike, so replace "false" is false and freeze 1
freezes; a MIMO device set takes receive and transmit channel types; deletion is serialised
from lookup to completion so two concurrent reclaims cannot take a third channel; tune_gain
refuses a gain or AGC key the device lacks; start_iq_recording checks the name first and cleans
up by UID; describe_settings emits a definition matched by name; remove_last_deviceset reports
a timeout; a device set a failed listen or scan created is removed again.
Capture: a name resolving to the capture directory itself is refused, a drive root works, and
files are listed by prefix rather than wildcard. The audio clock starts before the wait for the
sample rate. Subscriptions are capped per session, device set URIs checked, and absent device
sets skipped by the poll. The Codex writer drops dotted managed keys and refuses a spelling it
cannot rewrite rather than adding a duplicate table.
Bridge: one session at a time when SDRangel comes back, the stream socket is shut down rather
than closed from the other thread, SIGPIPE cannot end the process, and a failed notification
gets no reply.
Also: tool calls and audio captures give up when the server stops, so stopping the feature
cannot deadlock on a call waiting for the main thread; channels are held by UID throughout;
socket timeouts in the bridge; ResourceNotFound for a resources/read of a URI that is not there.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>