Closed Bug 1908095 Opened 4 months ago Closed 3 months ago

Breakpoints are still triggered after being deleted

Categories

(DevTools :: Debugger, defect, P2)

Firefox 128
defect

Tracking

(firefox-esr115 unaffected, firefox-esr128 fixed, firefox129 wontfix, firefox130 fixed, firefox131 fixed)

VERIFIED FIXED
131 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr128 --- fixed
firefox129 --- wontfix
firefox130 --- fixed
firefox131 --- fixed

People

(Reporter: 1250079251, Assigned: jdescottes)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: regression)

Attachments

(5 files)

Attached video 2024-07-16_17-04-15.mkv

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0

Steps to reproduce:

I debugged in a new environment created in about:profiles

I debugged tab-stash via about:debugging.

I set a breakpoint at /assets/oops-notification.js:2263 and removed it


tab-stash-3.0.1: https://addons.mozilla.org/en-US/firefox/addon/tab-stash/

Actual results:

But when I removed the breakpoint, it was still triggered by Firefox.

Expected results:

Deleted breakpoints should not be triggered

Steps missing from Steps to reproduce:

  • Create a new tab

This action will trigger the breakpoint

The Bugbug bot thinks this bug should belong to the 'DevTools::Debugger' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Debugger
Product: Firefox → DevTools

Had a similar issue when testing webextensions previously, will try to reproduce.

Flags: needinfo?(jdescottes)

My issue was different: Bug 1869495.

But I do reproduce with the STRs here. You don't even have to hit the breakpoint, just add and remove, then add a tab.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(jdescottes)

https://searchfox.org/mozilla-central/rev/e637cd67f98ed4272d13a96db9a7674689122dcb/devtools/client/debugger/src/client/firefox/commands.js#244-269

async function removeBreakpoint(location) {
  delete breakpoints[makeBreakpointServerLocationId(location)];

  const hasWatcherSupport = commands.targetCommand.hasTargetWatcherSupport();
  if (!hasWatcherSupport) {
    // Without watcher support, unconditionally forward removeBreakpoint to all threads.
    return forEachThread(async thread => thread.removeBreakpoint(location));
  }
  const breakpointsFront =
    await commands.targetCommand.watcherFront.getBreakpointListActor();
  await breakpointsFront.removeBreakpoint(location);

  // Call removeBreakpoint for threads linked to targets
  // not managed by the watcher.
  return forEachThread(async thread => {
    if (
      !commands.targetCommand.hasTargetWatcherSupport(
        thread.targetFront.targetType
      )
    ) {
      return thread.removeBreakpoint(location);
    }

    return Promise.resolve();
  });
}

For webextension targets, we only call

  const breakpointsFront =
    await commands.targetCommand.watcherFront.getBreakpointListActor();
  await breakpointsFront.removeBreakpoint(location);

Not sure I completely remember the situation for webextensions though.
I don't see any call actually processing the removed data entries, but maybe I'm looking at the wrong spot?

(In reply to Julian Descottes [:jdescottes] from comment #5)

For webextension targets, we only call

  const breakpointsFront =
    await commands.targetCommand.watcherFront.getBreakpointListActor();
  await breakpointsFront.removeBreakpoint(location);

Not sure I completely remember the situation for webextensions though.
I don't see any call actually processing the removed data entries, but maybe I'm looking at the wrong spot?

In theory, it should be going through this code:
https://searchfox.org/mozilla-central/rev/e637cd67f98ed4272d13a96db9a7674689122dcb/devtools/server/connectors/js-process-actor/DevToolsProcessChild.sys.mjs#393-417
Is targetActors empty for some reason?

The issue is when removing the breakpoint, and it seems we don't have any special code to handle webextensions there:
https://searchfox.org/mozilla-central/rev/e637cd67f98ed4272d13a96db9a7674689122dcb/devtools/server/connectors/js-process-actor/DevToolsProcessChild.sys.mjs#455-476

#removeSessionDataEntry(watcherActorID, type, entries) {
  const watcherDataObject =
    ContentProcessWatcherRegistry.getWatcherDataObject(watcherActorID, true);

  // When we unwatch resources after targets during the devtools shutdown,
  // the watcher will be removed on last target type unwatch.
  if (!watcherDataObject) {
    return;
  }

  // Maintain the copy of `sessionData` so that it is up-to-date when
  // a new worker target needs to be instantiated
  lazy.SessionDataHelpers.removeSessionDataEntry(
    watcherDataObject.sessionData,
    type,
    entries
  );

  for (const targetActor of watcherDataObject.actors) {
    targetActor.removeSessionDataEntry(type, entries);
  }
}

Good catch! That must cause various issues, beyond breakpoints...

Will try to write some tests while fixing this.

Assignee: nobody → jdescottes
Status: NEW → ASSIGNED

Fix removing breakpoints in webextension toolboxes and watcher targets, add tests to cover both scenarios

Severity: -- → S3
Priority: -- → P2
Pushed by jdescottes@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a57fba6a542b [devtools] removeSessionDataEntry for webextension toolboxes and watcher targets r=ochameau,devtools-reviewers https://hg.mozilla.org/integration/autoland/rev/a6ccaa04f182 [devtools] Regenerate debugger mochitest sourcemap resources r=devtools-reviewers,nchevobbe
Status: ASSIGNED → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 131 Branch
Keywords: regression
Regressed by: 1648499

The fix has now landed on our Nightly channel. If possible, could you try the latest Nightly and verify this is fixed?

Flags: needinfo?(1250079251)

Set release status flags based on info from the regressing bug 1648499

Did you want to nominate this for uplift? Fx130 goes to RC next week.

Flags: needinfo?(jdescottes)
Flags: in-testsuite+

Oh right I forgot about this during mozweek.
It would be great to uplift it if possible, this can be quite annoying when debugging webextensions and workers.

Flags: needinfo?(jdescottes)

Comment on attachment 9416815 [details]
Bug 1908095 - [devtools] removeSessionDataEntry for webextension toolboxes and watcher targets

Beta/Release Uplift Approval Request

  • User impact if declined: Unable to remove breakpoints when debugging webextensions or workers
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Devtools only change, which is applying the same logic to handle devtools session data (including breakpoints) for webextension/worker targets in the same way as for regular web targets.
  • String changes made/needed:
  • Is Android affected?: No
Attachment #9416815 - Flags: approval-mozilla-beta?

Comment on attachment 9416815 [details]
Bug 1908095 - [devtools] removeSessionDataEntry for webextension toolboxes and watcher targets

Approved for 130.0b8.

Attachment #9416815 - Flags: approval-mozilla-esr128?
Attachment #9416815 - Flags: approval-mozilla-beta?
Attachment #9416815 - Flags: approval-mozilla-beta+
Attachment #9417333 - Flags: approval-mozilla-esr128?
Attachment #9417333 - Flags: approval-mozilla-beta+

Comment on attachment 9416815 [details]
Bug 1908095 - [devtools] removeSessionDataEntry for webextension toolboxes and watcher targets

Approved for 128.2esr.

Attachment #9416815 - Flags: approval-mozilla-esr128? → approval-mozilla-esr128+
Attachment #9417333 - Flags: approval-mozilla-esr128? → approval-mozilla-esr128+

Feel free to wontfix this for ESR128 if it's not a trivial fix-up.

I imagine the patch itself is fine, and it's rather the test update which might be missing some other intermediary patches?
Let's see if the test fails without the updates here. If not, I think we can probably remove the part which tests workers from the test patch, there is already a test for webextensions, and both use the same codepath, so I think it would give enough coverage.

Flags: needinfo?(jdescottes)

I verified on NIGHTLY

Status: RESOLVED → VERIFIED
Flags: needinfo?(1250079251)

cool! The bug is gone!

Actually the implementation for workers was a bit different in 128, but it should be easy to adapt.

Fix removing breakpoints in webextension toolboxes and watcher targets, add tests to cover both scenarios
Implementation update to fit 128 ESR

Did a try push with my changes on top of ESR128 https://treeherder.mozilla.org/jobs?repo=try&revision=be37f112f849da8a8d24f99fd09e38b473c69dbe, hopefully this can tell us if the adapted version can work.

There was an error in my first patch, new try push at https://treeherder.mozilla.org/jobs?repo=try&revision=b2c00ca39a5c211eed24af05f6f91bc360167b10

Ryan: Could we use D219752 and D219753 for the ESR 128 uplift? The tests seem to be fine on my last try push

Flags: needinfo?(ryanvm)
Flags: needinfo?(ryanvm)
Attachment #9416815 - Flags: approval-mozilla-esr128+
Attachment #9417333 - Flags: approval-mozilla-esr128+

Sure, thanks for doing the rebase!

Attachment #9420128 - Flags: approval-mozilla-esr128?
Attachment #9420130 - Flags: approval-mozilla-esr128?
Attachment #9420128 - Flags: approval-mozilla-esr128? → approval-mozilla-esr128+
Attachment #9420130 - Flags: approval-mozilla-esr128? → approval-mozilla-esr128+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: