Skip to content

Analyzer hang on Linux due to out of file watchers #61931

@davidmorgan

Description

@davidmorgan

On Linux file watchers are a limited resource with some arbitrary (system config dependent!) fixed limit.

If there are no more file watchers left, dart analyze can hang forever.

The problem is that analyzer code in context_manager.dart assumes a watcher failure is temporary and tries again, but it will not succeed until more watchers become available. So, it needs to give up at some point.

The permanent failure can be identified by the error message, "(OS Error: No space left on device, errno = 28)", yes, Linux reports "not enough watchers" as "no space left", which has been confusing people for a very long time :)

To repro, first exhaust your file watchers. This is system dependent, on mine I can do

sudo sysctl -w fs.inotify.max_user_watches=0

to set the max number of watchers to zero.

Then, running

dart analyze lib pubspec.yaml

hangs. (Other invocations don't hang, not sure exactly why, I guess a different number of watchers is created).

The number of watches should reset on reboot, or you can change it back, on my system the old value was about 4000000

sudo sysctl -w fs.inotify.max_user_watches=4000000

Metadata

Metadata

Assignees

Labels

P1A high priority bug; for example, a single project is unusable or has many test failuresarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.type-performanceIssue relates to performance or code size

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions