Skip to content

Guard all remaining null spectrum() dereferences in multi-pan mode (#1199)#1249

Closed
aethersdr-agent[bot] wants to merge 1 commit intomainfrom
aetherclaude/issue-1199
Closed

Guard all remaining null spectrum() dereferences in multi-pan mode (#1199)#1249
aethersdr-agent[bot] wants to merge 1 commit intomainfrom
aetherclaude/issue-1199

Conversation

@aethersdr-agent
Copy link
Copy Markdown
Contributor

Summary

Fixes #1199


Generated by AetherClaude (automated agent for AetherSDR)

…1199)

The previous fix (36b0a5e, #1146) guarded three call sites where
spectrum() could return null during band changes, but many more
remained unguarded. When the radio removes and recreates panadapters
during a band change with 2+ slices, these unguarded dereferences
cause a SIGSEGV — particularly in captureCurrentBandState(),
restoreBandState(), updateSplitState(), onSliceRemoved(),
disableSplit(), and the panadapterInfoChanged handler.

Added null checks at all remaining unguarded spectrum() call sites.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@aethersdr-agent aethersdr-agent bot mentioned this pull request Apr 13, 2026
2 tasks
@aethersdr-agent
Copy link
Copy Markdown
Contributor Author

CI Build Failure Analysis

The build and analyze (cpp) checks both failed at the Build step. The CodeQL analysis failure is a cascade — it can't analyze code that doesn't compile.

Root cause: CI infrastructure, not your code

Your changes to MainWindow.cpp (the null-safety guards for spectrum()) are correct and clean — this is not a problem with your PR.

The build failure is because this branch is based on 517c4a2 (the first cJSON stub fix), but it's missing three subsequent CI fixes that landed on main after your branch point:

Commit Fix
0643620 Stub all cJSON includes — broker_control.h and json_help.h still had #include <cjson/cJSON.h>
c703055 Fix Windows/macOS builds for bundled mosquitto (pthreads, arc4random)
3c2ed4c Define LIBMOSQUITTO_STATIC for MSVC static linking

The CI container doesn't have the cjson development headers installed, so the un-stubbed #include <cjson/cJSON.h> in third_party/mosquitto/include/mosquitto/broker_control.h and third_party/mosquitto/src/json_help.h causes the build to fail before it even gets to your MainWindow.cpp changes.

How to fix

Rebase onto current main to pick up the mosquitto CI fixes:

git fetch upstream
git rebase upstream/main
git push --force-with-lease

That should be all that's needed — CI should go green after the rebase.

About the code itself

The null-safety guards look good. Protecting against spectrum() returning nullptr in multi-pan mode is the right approach, and the pattern of if (auto* sw = spectrum()) is consistent with how we handle nullable widget pointers elsewhere in the codebase.

Thanks for working on #1199!

@luigiverdicchio1-prog
Copy link
Copy Markdown

The problem also occurs with version 8.11. I repeat, with a single slice everything works normally. The crash problem is with 2 slices active during bandwidth changes. Is there a way to upload a video?
Lou IK8HCG

@aethersdr-agent
Copy link
Copy Markdown
Contributor Author

CI Failure Update — commit dfa7963

The build and analyze (cpp) checks are still failing at the Build step on the latest push. The CodeQL (analyze (cpp)) failure is a cascade — it can't analyze code that doesn't compile, so that's expected.

This is a CI infrastructure issue, not a problem with your code

Your MainWindow.cpp changes are correct — the if (auto* sw = spectrum()) null guards are exactly the right pattern for multi-pan mode safety, and they're consistent with how nullable widget pointers are handled elsewhere in the codebase.

What's happening

The branch is still missing the mosquitto/cJSON CI fixes that landed on main after your branch point. The CI container doesn't have cjson dev headers, so the un-stubbed #include <cjson/cJSON.h> in third_party/mosquitto/ causes the build to fail before it reaches any of your changes. The relevant fixes on main:

Commit What it fixed
0643620 Stub all cJSON includes (broker_control.h, json_help.h)
c703055 Fix Windows/macOS bundled mosquitto builds
3c2ed4c Define LIBMOSQUITTO_STATIC for static linking

Fix

Rebase onto current main to pick up these fixes:

git fetch origin
git rebase origin/main
git push --force-with-lease

CI should go green after that — your code changes don't need any modifications.

Note on @luigiverdicchio1-prog's comment

The crash with 2 slices during bandwidth changes that Lou (IK8HCG) reported above is exactly the kind of null-dereference scenario this PR guards against. Getting this merged will help with that — thanks for the report, Lou! If the issue persists after this lands, please open a new issue with reproduction steps and we'll dig deeper.


Automated analysis by AetherClaude

@ten9876
Copy link
Copy Markdown
Owner

ten9876 commented Apr 14, 2026

Claude here — taking this via a rebased branch with one conflict resolved (antenna wiring already moved to wirePanadapter in #1276).

73, Jeremy KK7GWY & Claude (AI dev partner)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash

3 participants