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

Fix SIOOBE in 'ParticipantUtils.getMavenProperty' #452

Conversation

vrubezhny
Copy link
Contributor

    Jul 25, 2023 3:03:17 PM org.eclipse.lemminx.extensions.maven.participants.codeaction.InlinePropertyCodeAction doCodeActionUnconditional
    SEVERE: begin 2, end 1, length 2
    java.lang.StringIndexOutOfBoundsException: begin 2, end 1, length 2
            at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4602)
            at java.base/java.lang.String.substring(String.java:2705)
            at org.eclipse.lemminx.extensions.maven.utils.ParticipantUtils.getMavenProperty(ParticipantUtils.java:295)
            at org.eclipse.lemminx.extensions.maven.participants.codeaction.InlinePropertyCodeAction.doCodeActionUnconditional(InlinePropertyCodeAction.java:55)
            at org.eclipse.lemminx.services.XMLCodeActions.doCodeActions(XMLCodeActions.java:81)
            at org.eclipse.lemminx.services.XMLLanguageService.doCodeActions(XMLLanguageService.java:284)
            at org.eclipse.lemminx.XMLTextDocumentService.lambda$codeAction$24(XMLTextDocumentService.java:502)
            at org.eclipse.lemminx.commons.ModelTextDocuments.lambda$computeModelAsync$0(ModelTextDocuments.java:118)
            at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
            at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
            at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
            at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
            at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
            at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
            at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
    
    Jul 25, 2023 3:03:17 PM org.eclipse.lemminx.extensions.maven.participants.codeaction.ExtractPropertyCodeAction doCodeActionUnconditional
    SEVERE: begin 2, end 1, length 2
    java.lang.StringIndexOutOfBoundsException: begin 2, end 1, length 2
            at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4602)
            at java.base/java.lang.String.substring(String.java:2705)
            at org.eclipse.lemminx.extensions.maven.utils.ParticipantUtils.getMavenProperty(ParticipantUtils.java:295)
            at org.eclipse.lemminx.extensions.maven.participants.codeaction.ExtractPropertyCodeAction.doCodeActionUnconditional(ExtractPropertyCodeAction.java:113)
            at org.eclipse.lemminx.services.XMLCodeActions.doCodeActions(XMLCodeActions.java:81)
            at org.eclipse.lemminx.services.XMLLanguageService.doCodeActions(XMLLanguageService.java:284)
            at org.eclipse.lemminx.XMLTextDocumentService.lambda$codeAction$24(XMLTextDocumentService.java:502)
            at org.eclipse.lemminx.commons.ModelTextDocuments.lambda$computeModelAsync$0(ModelTextDocuments.java:118)
            at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
            at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
            at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
            at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
            at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
            at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
            at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

@vrubezhny vrubezhny marked this pull request as draft July 25, 2023 16:21
```
Jul 25, 2023 3:03:17 PM org.eclipse.lemminx.extensions.maven.participants.codeaction.InlinePropertyCodeAction doCodeActionUnconditional
SEVERE: begin 2, end 1, length 2
java.lang.StringIndexOutOfBoundsException: begin 2, end 1, length 2
	at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4602)
	at java.base/java.lang.String.substring(String.java:2705)
	at org.eclipse.lemminx.extensions.maven.utils.ParticipantUtils.getMavenProperty(ParticipantUtils.java:295)
	at org.eclipse.lemminx.extensions.maven.participants.codeaction.InlinePropertyCodeAction.doCodeActionUnconditional(InlinePropertyCodeAction.java:55)
	at org.eclipse.lemminx.services.XMLCodeActions.doCodeActions(XMLCodeActions.java:81)
	at org.eclipse.lemminx.services.XMLLanguageService.doCodeActions(XMLLanguageService.java:284)
	at org.eclipse.lemminx.XMLTextDocumentService.lambda$codeAction$24(XMLTextDocumentService.java:502)
	at org.eclipse.lemminx.commons.ModelTextDocuments.lambda$computeModelAsync$0(ModelTextDocuments.java:118)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

Jul 25, 2023 3:03:17 PM org.eclipse.lemminx.extensions.maven.participants.codeaction.ExtractPropertyCodeAction doCodeActionUnconditional
SEVERE: begin 2, end 1, length 2
java.lang.StringIndexOutOfBoundsException: begin 2, end 1, length 2
	at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4602)
	at java.base/java.lang.String.substring(String.java:2705)
	at org.eclipse.lemminx.extensions.maven.utils.ParticipantUtils.getMavenProperty(ParticipantUtils.java:295)
	at org.eclipse.lemminx.extensions.maven.participants.codeaction.ExtractPropertyCodeAction.doCodeActionUnconditional(ExtractPropertyCodeAction.java:113)
	at org.eclipse.lemminx.services.XMLCodeActions.doCodeActions(XMLCodeActions.java:81)
	at org.eclipse.lemminx.services.XMLLanguageService.doCodeActions(XMLLanguageService.java:284)
	at org.eclipse.lemminx.XMLTextDocumentService.lambda$codeAction$24(XMLTextDocumentService.java:502)
	at org.eclipse.lemminx.commons.ModelTextDocuments.lambda$computeModelAsync$0(ModelTextDocuments.java:118)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
```
@vrubezhny vrubezhny force-pushed the fixSIOOBInParticipantUtils_getMavenProperty branch from ce3769d to 091cb27 Compare July 25, 2023 16:29
@vrubezhny vrubezhny marked this pull request as ready for review July 25, 2023 16:29
@vrubezhny vrubezhny merged commit d20ffcf into eclipse:master Jul 25, 2023
5 checks passed
@rgrunber
Copy link
Contributor

I just ran into this today :

Jul. 26, 2023 8:37:06 P.M. org.eclipse.lemminx.extensions.maven.utils.ParticipantUtils getMavenProperty
SEVERE: java.lang.StringIndexOutOfBoundsException: begin 0, end 37, length 18
java.lang.StringIndexOutOfBoundsException: begin 0, end 37, length 18
    at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4602)
    at java.base/java.lang.String.substring(String.java:2705)
    at org.eclipse.lemminx.extensions.maven.utils.ParticipantUtils.getMavenProperty(ParticipantUtils.java:329)
    at org.eclipse.lemminx.extensions.maven.participants.codeaction.InlinePropertyCodeAction.doCodeActionUnconditional(InlinePropertyCodeAction.java:57)
    at org.eclipse.lemminx.services.XMLCodeActions.doCodeActions(XMLCodeActions.java:81)
    at org.eclipse.lemminx.services.XMLLanguageService.doCodeActions(XMLLanguageService.java:284)
    at org.eclipse.lemminx.XMLTextDocumentService.lambda$codeAction$24(XMLTextDocumentService.java:502)
    at org.eclipse.lemminx.commons.ModelTextDocuments.lambda$computeModelAsync$0(ModelTextDocuments.java:118)
    at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
    at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

I think I was built on top of this commit.

@vrubezhny
Copy link
Contributor Author

vrubezhny commented Jul 27, 2023

I think I was built on top of this commit.

@rgrunber What Lemminx-Maven version do you use and how - M2E-Core Editor Lemminx or VSCode-XML?
And are you clearly able to reproduce the issue?

I suspect hat it's possible that document was modified between the codeActions request was sent and code actions calculation was actually started. I have similar issues with diagnostics calculations - do you see any "strange" exceptions like the following:

org.apache.maven.plugin.InvalidPluginDescriptorException: Unable to resolve gins>
			<plugin>
	:exus</groupId>
				<artif

or

org.apache.maven.plugin.InvalidPluginDescriptorException: Unable to resolve roupId>org.codehaus:factId>plexus-component-m

?

Here it's for sure, the ranges in diagnostic request's node are not coinciding with its DOMDocument's real text...

@rgrunber
Copy link
Contributor

I'm on 7a00206 . I run in vscode-xml with :

"xml.extension.jars": [
        "/home/rgrunber/git/lemminx-maven/lemminx-maven/target/vscode-lemminx-maven-jars/*.jar"
    ],

I'm not sure what causes it to reproduce. I'm just clicking around and occasionally editing things. This time I got :

Jul. 27, 2023 3:45:16 P.M. org.eclipse.lemminx.extensions.maven.utils.ParticipantUtils getMavenProperty
SEVERE: java.lang.StringIndexOutOfBoundsException: begin 0, end 29, length 16
java.lang.StringIndexOutOfBoundsException: begin 0, end 29, length 16
	at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4602)
	at java.base/java.lang.String.substring(String.java:2705)
	at org.eclipse.lemminx.extensions.maven.utils.ParticipantUtils.getMavenProperty(ParticipantUtils.java:329)
	at org.eclipse.lemminx.extensions.maven.utils.ParticipantUtils.getMavenPropertyInRequest(ParticipantUtils.java:316)
	at org.eclipse.lemminx.extensions.maven.participants.definition.MavenDefinitionParticipant.findMavenPropertyLocation(MavenDefinitionParticipant.java:186)
	at org.eclipse.lemminx.extensions.maven.participants.definition.MavenDefinitionParticipant.findDefinition(MavenDefinitionParticipant.java:64)
	at org.eclipse.lemminx.services.XMLDefinition.findDefinition(XMLDefinition.java:62)
	at org.eclipse.lemminx.services.XMLLanguageService.findDefinition(XMLLanguageService.java:264)
	at org.eclipse.lemminx.XMLTextDocumentService.lambda$definition$18(XMLTextDocumentService.java:443)
	at org.eclipse.lemminx.commons.ModelTextDocuments.lambda$computeModelAsync$0(ModelTextDocuments.java:118)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

@vrubezhny
Copy link
Contributor Author

@rgrunber Yes, it's a real issue - is to be fixed with #466

Thanks for reporting it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants