New issue
Advanced search Search tips

Issue 741188 link

Starred by 5 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , iOS , Chrome , Mac , Fuchsia
Pri: 1
Type: Bug



Sign in to add a comment

File descriptors registered with FileDescriptorWatcher POSIX cannot be safely close()d

Project Member Reported by w...@chromium.org, Jul 11 2017

Issue description

The FileDescriptorWatcher POSIX wrapper is used by code running on TaskScheduler to watch for when file descriptors are readable/writable, on a dedicated I/O thread. The API has two issues in its current form:

1. It is not possible for calling code to protect against raciness when close()ing watched file-descriptors:
  a. The underlying WatchFileDescriptor call may be passed an invalid file-descriptor.
  b. The file-descriptor may be closed, and re-used, by the time WatchFileDescriptor executes, leading to the wrong file being watched.

2. The API provides no indication to the caller of whether the watch succeeded or failed:
  a. This makes it harder to diagnose brokenness in the underlying MessagePump*::FileDescriptorWatcher (see  issue 740305 ).
  b. This makes it harder to spot brokenness in production & test code via unit-tests (see  issue 740692 ).

#2 cannot be resolved without addressing #1, since there is currently no mechanism to provide the required synchronization.

For the wrapper to be safe, it should "own" the file-descriptors it watches, or the caller should be required to pass them to the FDW to be closed, rather than doing so itself.

 

Comment 1 by w...@chromium.org, Jul 11 2017

 Issue 733440  also encountered some of the issues with the current API/impl, it seems.

Comment 2 by pkl@chromium.org, Jul 17 2017

wez: is something already working on this?

Comment 3 by pkl@chromium.org, Jul 17 2017

s/something/someone/ 

Comment 4 by w...@chromium.org, Jul 17 2017

Re #3: Not that I'm aware of, no; our plan was to meet w/ fdoray@ to discuss potential fixes to the FDW design to address these issues.  Are you volunteering to work on that? :)

Comment 5 by pkl@chromium.org, Jul 24 2017

Cc: rohitrao@chromium.org
No, I'm not volunteering :)
Just trying to do bug triage.
Do you anticipate the solution for Mac to be different from iOS'?

Comment 6 by w...@chromium.org, Jul 24 2017

Re #5: The FileDescriptorWatcher POSIX wrapper is used across all the POSIX-ish platforms, so no there is nothing Mac vs iOS specific here.

Comment 7 by pkl@chromium.org, Aug 7 2017

Owner: robliao@chromium.org
Status: Assigned (was: Untriaged)
robliao: is this something in your area?
Cc: -fdoray@chromium.org robliao@chromium.org
Owner: fdoray@chromium.org
fdoray: Would be a good initial triager for this.
Can an update be posted to this bug please? It is a P1 that was targeted for M61.
Cc: linds...@chromium.org
What's the plan for the tentative fix?

Comment 13 by fdoray@google.com, Jan 21 (2 days ago)

Cc: fdoray@chromium.org mark@chromium.org
 Issue 922724  has been merged into this issue.

Sign in to add a comment