After upgrading to Linux 5.5 (I’m on Linux 5.5.2-1-MANJARO
), analysis in IntelliJ stops working after a while (analysis errors view doesn’t update anymore, formatting times out, no autocomplete, …).
The analyzer diagnostics page is still reachable after that happens, but it appears that the analysis server just stops serving regular requests. Interestingly, I can’t reproduce this with VS Code. I tried deleting ~/.dartServer/
, but that didn’t fix the problem.
I first thought this was an IntelliJ problem, but flutter/flutter#49185 (comment) makes me think that this is analyzer related. I wanted to open another issue here because for me that also happens on the non-Flutter Dart SDK (both stable & latest dev).
I can reproduce this consistently and on different projects, so I’d be glad to provide more information if that’s necessary.
The following simple program would reproduce the hang on a compute instance with 5.5.x linux kernel.
The parent process would then hang.
Based on my cursory analysis (I have never looked at this part of the code before) I think this is a bug in our code – we don’t seem to be using
epoll
correctly. We use edge-triggered mode for file descriptors (except server sockets). This mode comes with some warnings in the man pages. Namely it warns that if you useEPOLLET
you should onlyepoll_wait
after you have receivedEAGAIN
fromread
/write
– I don’t see us following this rule. We drain some available amount of bytes from the file descriptor but we don’t really drain it until we hitEAGAIN
(and we don’t even update our estimate of the available bytes as we are draining it – so we more bytes come while we are reading we are going to ignore that, which does not work with edge-triggered mode).I am not sure why this problem only surfaces now – but I see that there were some changes to the Kernel around epoll, so this might have caused it to surface.
We should either stop using ET mode or we should fix our code to follow man page guidelines.
Assigning to @zichangg for actual implementation work.
We should do a proper fix and backport it to stable.
A quick update:
I have a fix ready(https://dart-review.googlesource.com/c/sdk/+/136322).
But I still need to a review from @sortie before it lands.