Skip to content

fix: null dangling downstream input pointer on node removal - #38

Merged
striderZA merged 3 commits into
masterfrom
fix/pfb-channelizer-dangling-input-on-node-removal
Aug 3, 2026
Merged

fix: null dangling downstream input pointer on node removal#38
striderZA merged 3 commits into
masterfrom
fix/pfb-channelizer-dangling-input-on-node-removal

Conversation

@striderZA

Copy link
Copy Markdown
Owner

Summary

Fix a use-after-free segfault: deleting an upstream node (e.g. an RF ADC feeding a PFB Channelizer) freed the node's SignalNode synchronously mid-draw_ui(), leaving downstream components' node().inputs[] pointers dangling until the next frame's rewire — any widget dereferencing that pointer during the same frame's draw (PFBChannelizerWidget) crashed.

Related issue

Closes #37

Type of change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Build / CI

Test plan

  • cmake -B build -G Ninja && cmake --build build
  • ctest --test-dir build --output-on-failure
  • Manual verification steps:
    • New regression test (tests/test_issue37_pfb_input_removal.cpp) builds Generator→ADC→PFB, wires inputs via update_dsp(), then invokes the same onRemoveNode callback the UI uses on the ADC node, and asserts the PFB's node().inputs[0] is nulled immediately rather than left dangling.
    • Confirmed the test fails (dangling non-null pointer) against the pre-fix code (git stash on app.cpp/app.h), and passes with the fix.
    • Full existing suite green: tests.exe (217 cases / 65522 assertions), test_extensions, test_component_authoring, test_attenuator, test_combiner.
    • Full tiny-rf-simulator app target builds and links cleanly.

Checklist

  • My code follows the existing code style (see .clang-format)
  • I ran clang-format -i on changed files (via scripts/format.sh)
  • I added or updated tests where appropriate
  • Existing tests still pass

Details

RfSimulatorApp::update_dsp()'s signal-routing loop is extracted into RfSimulatorApp::rewireInputs(). onRemoveNode now calls rewireInputs() immediately after ComponentRegistry::remove(), so every surviving component's node().inputs[] reflects the current graph topology (nulled for any severed source) before the rest of that frame's draw_ui() continues rendering. This closes the dangling-pointer window for every widget that reads node().inputs[] directly during draw (PFB channelizer grid, and similarly the inspector panel's input-frequency readout), not just the reported PFB crash.

Also documents the new safety contract in app/AGENTS.md.

@striderZA striderZA linked an issue Aug 3, 2026 that may be closed by this pull request
@striderZA
striderZA merged commit 10abe42 into master Aug 3, 2026
8 checks passed
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.

Segmentation Fault when removing PFB Channelizer input

1 participant