Fix crash when buffer is modified before callback fires#40
Open
benthamite wants to merge 3 commits intoemacs-languagetool:masterfrom
Open
Fix crash when buffer is modified before callback fires#40benthamite wants to merge 3 commits intoemacs-languagetool:masterfrom
benthamite wants to merge 3 commits intoemacs-languagetool:masterfrom
Conversation
Contributor
|
Thanks. Could you split the Could you plumb the tests into the Eask config? Is it feasible to run them as GitHub CI tests? |
Restructure the `condition-case' in `--read-results' to wrap the entire callback invocation. Previously the error handler's return value fell through to `mapcar' (causing "Wrong type argument: sequencep") and callback could be invoked twice (once with 'errored, once with 'finished). Include ERT tests covering callback semantics (dead source buffer, error handling, and successful parse).
Skip matches whose offsets fall outside the current buffer bounds instead of signaling `args-out-of-range'. The buffer may have been modified while the LanguageTool request was in flight. Include ERT tests for --check-all covering valid matches, out-of-bounds offsets, mixed results, empty matches, and multiline positions.
Update the Eask test script to run ERT tests and add the test target to the Makefile ci recipe so tests run in GitHub Actions.
7c846fd to
46b32d0
Compare
Contributor
Author
|
Yes, done. |
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.
Summary
This is a companion to #39. That PR guarded against the source buffer being killed before the
url-retrievecallback fires; this one guards against the buffer being modified (i.e. still alive, but with different contents).flycheck-languagetool--check-all: skip matches whoseoffset + lengthfalls outside the current buffer bounds instead of signalingargs-out-of-rangeflycheck-languagetool--read-results: move thecondition-caseto wrap the entire callback invocation, fixing two issues:mapcar, causing"Wrong type argument: sequencep"callbackcould be invoked twice (once with'errored, once with'finished)Together with #39, this covers all three async race conditions in the callback: buffer killed, buffer modified, and response parse failure.
Problem
When the source buffer is edited while the LanguageTool HTTP request is in flight, the byte offsets in the JSON response can exceed
(point-max). This causes:The
args-out-of-rangeerror in--check-allis caught by thecondition-caseerror handler, which calls(funcall callback 'errored ...). But because thecondition-casewas placed inside themapcarargument, the handler's return value is passed tomapcaras a sequence — triggering the second error. Withdebug-on-erroractive, this enters the Emacs debugger in a recursive edit, freezing the UI.Test plan
Includes 9 ERT tests covering:
point-maxare silently skippedoffset + lengthpastpoint-maxare silently skipped'interrupted'errored'finished