Closed Bug 1704683 Opened 5 years ago Closed 5 years ago

ScopedClose has a double-close bug

Categories

(Core :: XPCOM, defect)

defect

Tracking

()

RESOLVED FIXED
90 Branch
Tracking Status
firefox-esr78 --- wontfix
firefox88 --- wontfix
firefox89 --- wontfix
firefox90 --- fixed

People

(Reporter: jld, Assigned: gerard-majax)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 external file)

If the close syscall fails with EINTR, it's a complicated situation:

  1. On HP-UX, allegedly, it was necessary to retry the call to prevent a leak
  2. On many other Unix varieties, the fd will be closed and the call must not be retried
  3. POSIX doesn't specify what happens

(In contrast, for every other syscall that can fail with EINTR, it's generally necessary to retry.)

See also https://crbug.com/269623 and bug 1278361 comment #3 where this was discussed with in the context of Chromium's code and our downstream copy, and bug 1278361 comment #10 for details about macOS. In summary, every Unix we support will close the fd in this case.

So, the code that was added in bug 818106 could in theory cause a double-close bug, and close an unrelated fd opened concurrently by another thread, if it's interrupted by a signal (e.g., by the profiler on Linux).

This is simple to fix: remove the retry loop.

Assignee: nobody → lissyx+mozillians
Status: NEW → ASSIGNED
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch
Has Regression Range: --- → yes
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: