Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clangd worker crashes unexpectedly #10

Open
hamer0 opened this issue Jul 22, 2023 · 9 comments
Open

Clangd worker crashes unexpectedly #10

hamer0 opened this issue Jul 22, 2023 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@hamer0
Copy link
Collaborator

hamer0 commented Jul 22, 2023

I'm yet to find how to reproduce this issue, however the clangd worker sometimes crashes with the error "Maximum Call Stack Size Exceeded" in the emscripten generated file clangd.mjs. This could either be an issue in the js itself or within the clangd wasm. The error occurred on the first load of the site.

Not much that can be done until I can reproduce this issue. I'll add any updates here.

@hamer0 hamer0 added the bug Something isn't working label Jul 22, 2023
@hamer0
Copy link
Collaborator Author

hamer0 commented Jul 26, 2023

image

Here are the error logs after getting this error again. It happened on a recompile without reloading the page, although the cause still is not clear.

Note: I was wrong about where the error occurs in the original issue. It is reported as happening clangd.worker.js not clangd.mjs although there still is an error there too.

@hamer0
Copy link
Collaborator Author

hamer0 commented Aug 1, 2023

Turned on detailed clangd logging with the same error and it seems like the language server doesn't completely crash this time.

image

Although, the stack size exceeded error log doesn't show with this, so its unlikely that this is the full story. I want to say the problem is down to the worker thread spawning, but it still isn't completely clear why this would crash the whole language server and not just the thread.

@hamer0
Copy link
Collaborator Author

hamer0 commented Aug 2, 2023

Clearer view of the full clangd output and where the error occurs.
image

Seems to be an issue with the indexing. This process is likely recursive and therefore this may be why a stack overflow is happening.

Note that this is still only an occasional issue, it mostly indexes correctly with no error:
image

My only thoughts are that there could be differences in how the filesystem loads and something in that is causing a recursive call that never ends. All speculation though - further investigation is required...

@hamer0 hamer0 self-assigned this Aug 2, 2023
@hamer0 hamer0 pinned this issue Aug 2, 2023
@hamer0
Copy link
Collaborator Author

hamer0 commented Sep 11, 2023

Clangd often crashes on the first load when running in the deployed editor. Refreshing the page and letting it relaunch seems to always resolve the issue.

The bug may be a web assembly issue where not enough memory is allocated to the process initially.

@hamer0
Copy link
Collaborator Author

hamer0 commented Sep 13, 2023

Its worth noting this has been tested exclusively on Chrome.

@hamer0
Copy link
Collaborator Author

hamer0 commented Sep 14, 2023

Further testing shows clangd will always crash on Chrome without dev tools open. It also seems to always run without crashing on firefox.

@hamer0
Copy link
Collaborator Author

hamer0 commented Sep 14, 2023

Removing the api docs populator using the lsp prevents the error from happening on start up. The lsp will successfully launch, but will still crash soon after without dev tools open

hamer0 added a commit that referenced this issue Sep 14, 2023
This feature caused clangd to crash much quicker. In fact 2 maximum stack size errors are reported in the console when this feature is enabled.

Since api docs population is hacky anyway, it might be worth just leaving this out for now. Might make it just a little bit easier to fix #10
@hamer0
Copy link
Collaborator Author

hamer0 commented Sep 14, 2023

Setting intial wasm memory to the maximum size (link to code) does not resolve the issue.

@hamer0
Copy link
Collaborator Author

hamer0 commented Sep 14, 2023

Clangd does not work at all on safari on Mac, regardless of whether dev console is open
Screenshot 2023-09-14 at 14 45 48

compiler still works so it cannot be a general issue with wasm

Clangd crashes for a different reason in this example, but its still worth noting that clangd so far only reliably works in its current state using Firefox.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant