Closed Bug 1679911 Opened 4 years ago Closed 7 months ago

HttpChannelChild::TrySendDeletingChannel() doesn't work when called off the main thread

Categories

(Core :: Networking: HTTP, task, P2)

task

Tracking

()

RESOLVED FIXED
125 Branch
Tracking Status
firefox125 --- fixed

People

(Reporter: mccr8, Assigned: smayya)

References

(Blocks 1 open bug)

Details

(Whiteboard: [necko-triaged][necko-priority-next])

Attachments

(1 file)

This is another issue I noticed while reading over HttpChannelChild::Release. I'm not sure if it matters in practice.

Simplified a bit, the method does this:

  if (!mDeletingChannelSent.compareExchange(false, true)) {
    return;
  }

  if (NS_IsMainThread()) {
    ...
    return;
  }

  ...

  DebugOnly<nsresult> rv = neckoTarget->Dispatch(
      NewNonOwningRunnableMethod(
          "net::HttpChannelChild::TrySendDeletingChannel", this,
          &HttpChannelChild::TrySendDeletingChannel),
      NS_DISPATCH_NORMAL);

When called off the main thread when mDeletingChannelSent is false, it will first set mDeletingChannelSent to true. Then it will dispatch a runnable to the main thread that retries the method. Except that when it runs it will immediately return because we set mDeletingChannelSent to true before dispatching the runnable.

It feels like two possible solutions would be to either set mDeletingChannelSent back to false before dispatching the runnable (maybe this is a bad idea because the runnable has a non-owning call to |this|?) or calling a variant of TrySendDeletingChannel that skips the mDeletingChannelSent check (and presumably the main thread check). It is also possible that this is never (or rarely?) called off the main thread so this stuff could be deleted or turned into a crash or something.

Severity: -- → N/A
Priority: -- → P2
Whiteboard: [necko-triaged]

HttpChannelChild::TrySendDeletingChannel should be only called on main thread, so we should add an assertion to force this.

Whiteboard: [necko-triaged] → [necko-triaged][necko-priority-next]
Assignee: nobody → smayya
Pushed by smayya@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1feadb20c735 enforce HttpChannelChild::TrySendDeletingChannel() is called only in main thread. r=necko-reviewers,kershaw
Status: NEW → RESOLVED
Closed: 7 months ago
Resolution: --- → FIXED
Target Milestone: --- → 125 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: