Skip to content

Fix crash in DTMF generator - #10815

Merged
kryksyh merged 1 commit into
audacity:masterfrom
kryksyh:fix_crash_dtmf_generator
Apr 28, 2026
Merged

kryksyh merged 1 commit into
audacity:masterfrom
kryksyh:fix_crash_dtmf_generator

Conversation

@kryksyh

@kryksyh kryksyh commented Apr 28, 2026

Copy link
Copy Markdown
Member

Resolves: #10563

Fixes stack overflow, when a model update emits modifySettings

  • I signed CLA
  • The title of the pull request describes an issue it addresses
  • If changes are extensive, then there is a sequence of easily reviewable commits
  • Each commit's message describes its purpose and effects
  • There are no behavior changes unnecessary for the stated purpose of the PR

Recommended:

  • Each commit compiles and runs on my machine without known undesirable changes of behavior

QA:

  • Testflow test cases have been run

@kryksyh
kryksyh requested a review from luapmartin April 28, 2026 09:19
@kryksyh kryksyh self-assigned this Apr 28, 2026
@coderabbitai

coderabbitai Bot commented Apr 28, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: c6bc63b2-13b3-4c70-a1e2-b0437d18aa0c

📥 Commits

Reviewing files that changed from the base of the PR and between 9fb41ed2e71d5b121d100a5cb25156c5812b60c0 and 69acdd8.

📒 Files selected for processing (2)
  • src/effects/builtin/view/builtineffectmodel.cpp
  • src/effects/builtin/view/builtineffectmodel.h

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Fixed a reactive loop that could trigger unintended reloads when effect settings were changed; self-originated settings updates no longer cause redundant reloads. This prevents nested or overlapping self-notify flows and improves stability and responsiveness when adjusting effect settings. No public interfaces or external behaviors were changed.

Walkthrough

Replaces a boolean self-notify flag with an integer depth counter m_selfNotificationDepth on BuiltinEffectModel. doInit()'s settings-changed callback now suppresses doReload() when m_selfNotificationDepth > 0. modifySettings() increments the depth, calls instancesRegister()->notifyAboutSettingsChanged(m_instanceId), and decrements the depth via a scoped defer so nested or overlapping self-notifications are tracked and do not trigger reload handling.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant Model as BuiltinEffectModel
    participant Reg as InstancesRegister

    Caller->>Model: modifySettings()
    Note right of Model: m_selfNotificationDepth++
    Model->>Reg: notifyAboutSettingsChanged(instanceId)
    Reg->>Model: settingsChanged()
    alt m_selfNotificationDepth > 0
        Note right of Model: doReload() suppressed
    else
        Model->>Model: doReload()
    end
    Note right of Model: m_selfNotificationDepth-- (deferred)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • Fix crash in DTMF generator #10815: Modifies the same BuiltinEffectModel self-notification flow (adds m_selfNotificationDepth and scoped guards around notifyAboutSettingsChanged).
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix crash in DTMF generator' clearly and concisely summarizes the main change: addressing a crash in the DTMF generator functionality.
Description check ✅ Passed The description includes all required sections with the issue reference, motivation, and completed checklist items, though QA testflow cases were not run.
Linked Issues check ✅ Passed The code changes address the stack overflow in DTMF generator by implementing a depth counter to prevent recursive reload callbacks when settings are modified.
Out of Scope Changes check ✅ Passed All changes are scoped to BuiltinEffectModel to fix the recursive settings notification issue and are directly related to resolving the DTMF generator crash.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kryksyh
kryksyh force-pushed the fix_crash_dtmf_generator branch from ad5239c to e5c25e2 Compare April 28, 2026 09:21
@kryksyh
kryksyh force-pushed the fix_crash_dtmf_generator branch from e5c25e2 to fd6502b Compare April 28, 2026 09:21

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5343eccc-781e-4497-a106-a48b01b67383

📥 Commits

Reviewing files that changed from the base of the PR and between 5e211c6 and fd6502b569a61edc0c293d2c305ff43324f1925c.

📒 Files selected for processing (2)
  • src/effects/builtin/view/builtineffectmodel.cpp
  • src/effects/builtin/view/builtineffectmodel.h

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
src/effects/builtin/view/builtineffectmodel.h (1)

82-82: ⚠️ Potential issue | 🟠 Major

Replace boolean self-notification guard with nest-safe depth tracking.

Using a plain bool here is not re-entrancy safe: a nested modifySettings() can reset it before the outer notify chain completes, reopening the recursion path (affecting callback behavior at src/effects/builtin/view/builtineffectmodel.cpp Line 19 and notify sequence at Lines 79-81).

Proposed fix (depth guard + scoped decrement)
diff --git a/src/effects/builtin/view/builtineffectmodel.h b/src/effects/builtin/view/builtineffectmodel.h
@@
-    bool m_emittingSelfNotification = false;
+    int m_selfNotificationDepth = 0;
diff --git a/src/effects/builtin/view/builtineffectmodel.cpp b/src/effects/builtin/view/builtineffectmodel.cpp
@@
-        if (m_emittingSelfNotification) {
+        if (m_selfNotificationDepth > 0) {
             return;
         }
@@
-    m_emittingSelfNotification = true;
+    ++m_selfNotificationDepth;
+    struct DepthGuard {
+        int& depth;
+        ~DepthGuard() { --depth; }
+    } guard { m_selfNotificationDepth };
     instancesRegister()->notifyAboutSettingsChanged(m_instanceId);
-    m_emittingSelfNotification = false;

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5cdb65d5-82c3-499b-8448-3fa7782825f3

📥 Commits

Reviewing files that changed from the base of the PR and between fd6502b569a61edc0c293d2c305ff43324f1925c and 861338a90e7813f0efe382decdf7faf7320e970e.

📒 Files selected for processing (2)
  • src/effects/builtin/view/builtineffectmodel.cpp
  • src/effects/builtin/view/builtineffectmodel.h

@kryksyh
kryksyh force-pushed the fix_crash_dtmf_generator branch from 861338a to 9fb41ed Compare April 28, 2026 13:23
fixes stack overflow, when a model update emits modifySettings
@kryksyh
kryksyh force-pushed the fix_crash_dtmf_generator branch from 9fb41ed to 69acdd8 Compare April 28, 2026 14:21
@kryksyh
kryksyh merged commit 36c80f4 into audacity:master Apr 28, 2026
5 checks passed
@kryksyh
kryksyh deleted the fix_crash_dtmf_generator branch April 28, 2026 14:21
luapmartin added a commit to luapmartin/audacity that referenced this pull request May 15, 2026
* Move decimal-precision derivation into ParameterInfo with an override hook
  (saintmatthieu's audacity#2) and expose via NumDecimalsRole; cap at 6 fractional
  digits to keep numbers readable.
* Split units (short symbol, rendered inside the spinbox via measureUnitsSymbol)
  from description (longer hint, rendered as a trailing label in the row).
  Nyquist's ctrl.label now flows to ParameterInfo.description; VST3 keeps both
  fields populated as before.
* Extract GeneratedIncrementalPropertyControl with the isEditing gesture
  lifecycle and a re-entry guard against the model echo loop pending audacity#10815.
* Use focus-based gestures in the text control so a typed word is one undo step.
* Layout polish: slider/dropdown/numeric/text/file controls each have bounded
  widths so the row stays readable across plugin families; description label
  hoisted to the outer row with a maximumWidth + word-wrap; trailing fillWidth
  filler keeps the description packed against its control rather than at the
  far right.
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.

Attempt to open DTMF generator causes a crash

2 participants