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

Crash: StringIndexOutOfBoundsException in LatexAnnotatedTextBuilder #236

Closed
theFSO opened this issue Jan 27, 2021 · 2 comments
Closed

Crash: StringIndexOutOfBoundsException in LatexAnnotatedTextBuilder #236

theFSO opened this issue Jan 27, 2021 · 2 comments
Assignees
Labels
1-bug 🐛 Issue type: Bug report (something isn't working as expected) 2-confirmed Issue status: Confirmed, reproducible bug in LTeX 3-fixed Issue resolution: Issue has been fixed on the develop branch
Milestone

Comments

@theFSO
Copy link

theFSO commented Jan 27, 2021

Note: It is highly recommended to follow the instructions at https://valentjn.github.io/vscode-ltex/docs/contributing-code-issues.html#how-to-report-bugs and use the LTeX: Report bug in LTeX command from within Visual Studio Code. Per the contribution guidelines, deleting parts of the template or not filling in vital information may result in the issue to be immediately closed as invalid.

Describe the bug
LTex is not working properly, when executing Ltex:check current doc, it out put internal error

Steps to reproduce
Steps to reproduce the behavior:

  1. No idea this is the first time install Ltex for me and it just not working.

Expected behavior
How to fix it

Sample document
If the bug occurs for a specific document (e.g. LaTeX), please paste it here. If your document is very long or confidential, please create and attach a smaller example for which the bug still occurs so that we can reproduce it.

REPLACE_THIS_WITH_SAMPLE_DOCUMENT

LTeX configuration
Please paste all configuration settings starting with ltex. from your settings.json. You can help us by temporarily removing some irrelevant settings from your settings.json and see if the bug still occurs.

    "ltex.enabled": ["bibtex", "latex", "markdown", "rsweave"],
    "ltex.statusBarItem": true,
    "ltex.trace.server": "verbose",
    "ltex.additionalRules.enablePickyRules": true

"LTeX Language Server" log file
First, reproduce the bug. Then, go to ViewOutput and select LTeX Language Server in the drop-down list. Paste this log here:

Jan 28, 2021 3:22:17 AM org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint notify
INFO: Unsupported notification method: $/setTraceNotification
[Error - 3:22:23 AM] Registering progress handler for token {"uri":"file:///home/ubuntu/cs2me3/guoz59/A1/report/report.tex","operation":"checkDocument","counter":0} failed.
Error: Progress handler for token {"uri":"file:///home/ubuntu/cs2me3/guoz59/A1/report/report.tex","operation":"checkDocument","counter":0} already registered
	at Object.onProgress (/home/ubuntu/.vscode-server/extensions/valentjn.vscode-ltex-8.3.0/dist/extension.js:1:188606)
	at P.onProgress (/home/ubuntu/.vscode-server/extensions/valentjn.vscode-ltex-8.3.0/dist/extension.js:1:243094)
	at new t.ProgressPart (/home/ubuntu/.vscode-server/extensions/valentjn.vscode-ltex-8.3.0/dist/extension.js:1:282879)
	at /home/ubuntu/.vscode-server/extensions/valentjn.vscode-ltex-8.3.0/dist/extension.js:1:282605
	at /home/ubuntu/.vscode-server/extensions/valentjn.vscode-ltex-8.3.0/dist/extension.js:1:183064
	at /home/ubuntu/.vscode-server/extensions/valentjn.vscode-ltex-8.3.0/dist/extension.js:1:184106
	at Immediate._onImmediate (/home/ubuntu/.vscode-server/extensions/valentjn.vscode-ltex-8.3.0/dist/extension.js:1:186491)
	at processImmediate (internal/timers.js:439:21)
Jan 28, 2021 3:22:23 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint fallbackResponseError
SEVERE: Internal error: java.lang.StringIndexOutOfBoundsException: begin 1, end -1, length 0
java.util.concurrent.CompletionException: java.lang.StringIndexOutOfBoundsException: begin 1, end -1, length 0
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
	at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2073)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:212)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.StringIndexOutOfBoundsException: begin 1, end -1, length 0
	at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3319)
	at java.base/java.lang.String.substring(String.java:1874)
	at org.bsplines.ltexls.parsing.latex.LatexAnnotatedTextBuilder.addCode(LatexAnnotatedTextBuilder.java:510)
	at org.bsplines.ltexls.parsing.latex.LatexAnnotatedTextBuilder.addCode(LatexAnnotatedTextBuilder.java:26)
	at org.bsplines.ltexls.server.DocumentChecker.buildAnnotatedTextFragments(DocumentChecker.java:54)
	at org.bsplines.ltexls.server.DocumentChecker.check(DocumentChecker.java:193)
	at org.bsplines.ltexls.server.LtexTextDocumentItem.lambda$check$6(LtexTextDocumentItem.java:471)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)
	... 12 more

"LTeX Language Client" log file
First, set the ltex.trace.server setting in your settings.json to "verbose". Then, reload the VS Code window and reproduce the bug. Go to ViewOutput and select LTeX Language Client in the drop-down list. Paste this log here (note: it will contain your checked document):

[Trace - 3:22:23 AM] Received response 'workspace/executeCommand - (28)' in 68ms. Request failed: Internal error. (-32603).
Error data: "java.util.concurrent.CompletionException: java.lang.StringIndexOutOfBoundsException: begin 1, end -1, length 0\n\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)\n\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)\n\tat java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)\n\tat java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2073)\n\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:212)\n\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)\n\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)\n\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)\n\tat org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)\n\tat java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)\n\tat java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base/java.lang.Thread.run(Thread.java:834)\nCaused by: java.lang.StringIndexOutOfBoundsException: begin 1, end -1, length 0\n\tat java.base/java.lang.String.checkBoundsBeginEnd(String.java:3319)\n\tat java.base/java.lang.String.substring(String.java:1874)\n\tat org.bsplines.ltexls.parsing.latex.LatexAnnotatedTextBuilder.addCode(LatexAnnotatedTextBuilder.java:510)\n\tat org.bsplines.ltexls.parsing.latex.LatexAnnotatedTextBuilder.addCode(LatexAnnotatedTextBuilder.java:26)\n\tat org.bsplines.ltexls.server.DocumentChecker.buildAnnotatedTextFragments(DocumentChecker.java:54)\n\tat org.bsplines.ltexls.server.DocumentChecker.check(DocumentChecker.java:193)\n\tat org.bsplines.ltexls.server.LtexTextDocumentItem.lambda$check$6(LtexTextDocumentItem.java:471)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)\n\t... 12 more\n"

Version information
List here the version information of the relevant software.

  • Operating system: Linux (which distribution/version), macOS xx.xx, or Windows xx
  • VS Code: 1.52.1
  • vscode-ltex: 8.3.0
  • ltex-ls: x.xx (only if not using ltex-ls automatically downloaded by LTeX)
  • Java: x.xx (usually obtained with java -version, only if not using Java automatically downloaded by LTeX)

Additional context/information
You can add any other context or information about the problem here.

@theFSO theFSO added 1-bug 🐛 Issue type: Bug report (something isn't working as expected) 2-unconfirmed Issue status: Bug that needs to be reproduced (all new bugs have this label) labels Jan 27, 2021
@valentjn valentjn self-assigned this Jan 27, 2021
@valentjn valentjn added 2-confirmed Issue status: Confirmed, reproducible bug in LTeX and removed 2-unconfirmed Issue status: Bug that needs to be reproduced (all new bugs have this label) labels Jan 27, 2021
@valentjn valentjn added this to the 8.4.0 milestone Jan 27, 2021
@valentjn
Copy link
Owner

Thanks for the report. You have a \begin or \end without an argument ({environmentname}) somewhere in your document. As a workaround, add the argument and reload the VS Code window (Ctrl+PDeveloper: Reload Window).

@valentjn valentjn added the 3-fixed Issue resolution: Issue has been fixed on the develop branch label Jan 27, 2021
@valentjn valentjn changed the title LTex not working. Crash: StringIndexOutOfBoundsException in LatexAnnotatedTextBuilder Jan 27, 2021
@valentjn
Copy link
Owner

Fix released in 8.4.0.

me-johnomar added a commit to me-johnomar/ltex-ls that referenced this issue Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1-bug 🐛 Issue type: Bug report (something isn't working as expected) 2-confirmed Issue status: Confirmed, reproducible bug in LTeX 3-fixed Issue resolution: Issue has been fixed on the develop branch
Projects
None yet
Development

No branches or pull requests

2 participants