Initialize m_buf to nullptr before allocating the sample buffer
and initialize m_log2Interp to prevent use of indeterminate state.
Identified by cppcheck.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Value-initialize both sample buffers and initialize m_log2Decim
to prevent use of indeterminate member values.
Identified by cppcheck.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Other applications (e.g. SoapyPlutoSDR, used by gqrx) leave the RX LO
powered down when they close, so SDRangel only received the AD9361's
own noise. In FDD mode the Tx LO also stays up while no stream runs,
radiating LO leakage when the Tx device is merely opened.
Set the LO powerdown attribute explicitly: power the LO up when a
stream starts, down when it stops or fails, and power the Tx LO down
when the Tx device is opened. Applies to the input, output and MIMO
plugins.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RTTY, NAVTEX and ILS demods read logFilename/logEnabled from
getAdsbDemodSettings(), which is null for those channels, so a PATCH of
either key crashes SDRangel. Also fix M17 Mod reverseAPIChannelIndex
(read from NFM Mod settings), Audio CAT SISO settings get and XTRX MIMO
reverse API settings and report (Input instead of MIMO types), and
BladeRF2 Output title (BladeRF1 settings).
Fix TX scaling bug that was costing 10dB of output power at max gain.
Improve performance on Windows to reduce overruns at high sample rates.
Add underrun stats.
Display temperature.
Improve error handling.
Move setting device settings off GUI thread. For #1522
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>
Initialize the uninitialized Metis MISO UDP handler state variables so frame
tracking, buffer indexing, PTT state, hardware status, and power measurements
start with defined values.
These members were previously left uninitialized, allowing protocol and
hardware state to contain indeterminate values before being updated.
This resolves the uninitialized member findings reported by Coverity
(UNINIT_CTOR).
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Initialize m_sampleFifo to nullptr and m_fcPos to zero so the BladeRF2 output
thread starts with defined FIFO and frequency position state.
The members were previously left uninitialized, allowing output processing to
use indeterminate state before the FIFO or frequency position was configured.
This resolves the uninitialized member findings reported by Coverity
(UNINIT_CTOR).
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Initialize m_log2Decim and m_fcPos to zero so the BladeRF2 input thread starts
with defined decimation and frequency position state before either value is
configured.
The members were previously left uninitialized, allowing input processing to
use indeterminate configuration values.
This resolves the uninitialized member findings reported by Coverity
(UNINIT_CTOR).
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Initialize m_iqOrder to false in resetToDefaults() so AudioCAT SISO settings
start with a defined IQ ordering state.
The member was previously left uninitialized when the default constructor
called resetToDefaults(), allowing the IQ ordering configuration to contain an
indeterminate value.
This resolves the uninitialized member finding reported by Coverity
(UNINIT_CTOR).
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Copy m_iqOrder in the AudioCAT SISO settings copy constructor so copied
settings retain the same IQ ordering configuration as the source object.
The member was previously left uninitialized, causing copied settings to
contain an indeterminate IQ ordering value.
This resolves the uninitialized member finding reported by Coverity
(UNINIT_CTOR).
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Initialize m_rig to nullptr and m_rxSampleRate to zero so the AudioCAT SISO CAT
worker starts with defined CAT and sample rate state.
The members were previously left uninitialized, allowing CAT and sample rate
processing to use indeterminate values.
This resolves the uninitialized member findings reported by Coverity
(UNINIT_CTOR).
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Initialize m_fcPos to zero so the AudioCAT input worker starts with a defined
frequency position before one is configured.
The member was previously left uninitialized, allowing frequency position
processing to use an indeterminate value.
This resolves the uninitialized member finding reported by Coverity
(UNINIT_CTOR).
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Initialize the previously uninitialized sample FIFO and frequency position
members to defined values to eliminate cppcheck UNINIT_CTOR warnings. This
ensures the output thread starts with a known state and avoids undefined
behavior from reading uninitialized values.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Initialize the previously uninitialized log2 decimation and frequency position
members to defined values to eliminate cppcheck UNINIT_CTOR warnings. This
ensures the thread starts with a known acquisition state and avoids undefined
behavior from reading uninitialized values.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Zero-initialize the Metis MISO accumulators to eliminate the cppcheck
UNINIT_CTOR warning. This ensures all accumulator values start in a defined
state before resetCounters() and subsequent processing.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
The same fix as da31464dd for the plugins whose applySettings takes the key list first, which
that sweep missed: 35 channels, modulators, sinks, sources and one MIMO device copied the
whole settings struct on every message, so a GUI message with no keys arriving just after an
API patch put the old values back. The DSD demodulator lost the deviation set at creation
this way.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
QMessageBox::information() and friends build the box on the stack, parent
it to the calling widget and run a nested event loop in exec(). If the
parent is closed while the box is open, which the Web API can do at any
time, the parent deletes the box and its children and the heap is
corrupted.
MessageDialog offers the same calls, but the box is heap allocated, given
Qt::WA_DeleteOnClose and shown rather than exec'd, so nothing runs a
nested event loop and the box owns its own lifetime. A box with the same
text as one already up is raised instead of a second being created.
The trade off is that information(), warning() and critical() return
immediately and cannot report which button was pressed. question() takes
a callback for the cases that need the answer.
Converts the call sites in the device, channel and feature GUIs.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The generated SWG setters overwrite the string pointer without deleting
what is already there, and every webapiSettingsGet and webapiReportGet
calls init() first, which has allocated one. Each call therefore leaked a
QString per string field. Measured at 117 bytes per settings GET for the
Satellite Tracker, over 20,000 requests.
Assign in place when the pointer is already set, which is what these same
functions have always done for title and reverseAPIAddress. 394 sites
across webapiFormatChannelSettings, webapiFormatDeviceSettings,
webapiFormatFeatureSettings and the three report equivalents.
The webapiReverseSend* functions are deliberately left alone: they build a
fresh SWG object whose constructor leaves the pointers null, so passing a
new QString is correct there.
After the change the same measurement is flat, at 7 bytes per GET.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
m_running is used to synchronize the PlutoSDR manager and runner
threads. The manager-side startWork() and stopWork() functions control
whether the runner in run() should execute.
startWork() reads m_running before starting the QThread and then waits
for run() to set it true. stopWork() sets m_running false to request
that the runner exit, while run() continuously reads the flag and sets
it false when it terminates.
These accesses occur across the manager and runner threads without
atomic synchronization. Make m_running an atomic_bool in the PlutoSDR
input, output, MIMO input, and MIMO output threads to eliminate the data
race identified by ThreadSanitizer.
This can prevent inconsistent thread state during user-driven device
start, stop, and reload operations, where the GUI can cause the manager
thread to start or stop a PlutoSDR runner while that runner is
processing.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Update the PlutoSDR input, output, and MIMO GUIs to properly handle the
SDRangel device engine entering the StError state following an
asynchronous device failure.
Clear the affected start/stop controls without emitting their signals,
preventing the GUI from attempting to restart or otherwise operate on a
device that has become unavailable. Indicate the error state visually
and display the error message reported by the device engine.
Stop updating device-specific status information while the device engine
is in the error state, since the underlying PlutoSDR device and streaming
resources may already have been closed.
This keeps the GUI state synchronized with the SDRangel device engine
after asynchronous failures such as a disconnected or unavailable
PlutoSDR.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Handle asynchronous errors reported by the PlutoSDR streaming threads and
transition the affected SDRangel device to a stopped and closed state.
When a PlutoSDR acquisition or generation thread reports an error, stop
and destroy the affected streaming threads and release the associated
buffers and device resources. For MIMO devices, shut down both acquisition
and generation paths and close the associated RX and TX resources so the
device is left in a consistent state.
Propagate the failure to the SDRangel device engine using the
DSPAcquisitionError and DSPGenerationError messages, including the
underlying error code and a message indicating that the PlutoSDR needs
to be restarted.
Also guard PlutoSDRInput::start() against an unavailable device parameter
object. This can occur after an asynchronous device failure has already
closed the device and prevents a subsequent start operation from
dereferencing an invalid device state.
This ensures that asynchronous failures such as a disconnected PlutoSDR
or an unrecoverable acquisition or generation error do not leave the
SDRangel device engine running against an unavailable device.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Detect negative return values from rxBufferRefill() and txBufferPush() in
the PlutoSDR input, output, and MIMO worker threads. These calls can fail
asynchronously after the device has successfully started, for example
when the PlutoSDR is disconnected or the underlying I/O connection
encounters an error.
Log the underlying error and emit the error code from the affected worker
thread instead of treating the negative return value as an ordinary
short or incomplete buffer.
This allows asynchronous PlutoSDR acquisition and generation failures to
be propagated out of the worker threads and handled by the device and DSP
error-handling infrastructure, rather than allowing the streaming thread
to continue operating with an invalid device state.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
cppcheck reported that the TestMISettings copy constructor did not
initialize member variable m_title:
Member variable 'TestMISettings::m_title' is not assigned in the copy
constructor. Should it be copied?
m_title is part of the serialized settings state, so ensure copied
TestMISettings instances preserve the configured title value.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Add memory buffer to Logger, so last 500 log messages can be included in crash report.
Generate and include stripped pdb files so stack trace can include function names.