fix: resolve critical deadlocks and infinite loops#117
Open
renich wants to merge 1 commit into
Open
Conversation
Author
553b417 to
41571b9
Compare
Assisted-by: Gemini <gemini@google.com>
41571b9 to
cb7a460
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses several fundamental stability issues that caused the Crystalline server to hang indefinitely or become unresponsive to
SIGINT(Ctrl+C). These fixes are critical for the reliability of the server, especially in single-threaded environments or when used with diverse LSP clients.Key Changes
1. Infinite Loop in Workspace Completion
Workspace#completion, the lexer loop was comparingtoken.type(an Enum) to a symbol (:EOF). This comparison always returnedfalse, causing the server to spin indefinitely when lexing comments..eof?and.comment?).2. Deadlock in Single-Threaded Mode (
-Dpreview_mtabsent)Analysis.spawn_dedicatedenqueued a fiber on the current thread and then immediately blocked the main fiber on a channel. In single-threaded mode, the scheduler never had a chance to switch to the compilation fiber, leading to a permanent deadlock.spawn_dedicatedto execute the compilation block immediately (synchronously) when multithreading is disabled, ensuring the channel is populated before the main fiber waits.3. Progress Report Hang
Progress#reportassumed all clients would respond to aworkDoneProgress/createrequest. If a client (or a test mock) didn't support progress or didn't send a response, the server would hang waiting for anon_responsecallback.work_done_progress. If unsupported, the report executes the block immediately rather than waiting for a client handshake.4. Buffered Sync Channel
sync_channelto ensure non-blocking completion of the compilation block.Verification
spec/reproduction_76_spec.crwhich empirically reproduces the comment-completion hang and verifies the fix.-Dpreview_mt) modes.SIGINTeven during heavy compilation tasks.Maintainer Note
These stability fixes are prerequisites for running the full test suite reliably. Without them, specific edge cases in comment lexing or single-threaded execution can cause the test runner itself to hang.
Assisted-by: Gemini gemini@google.com