TypeFox / yang-lsp

A Language Server for YANG
http://www.yang-central.org
Apache License 2.0
51 stars 13 forks source link

Invalid module crashes the server #214

Closed syyyr closed 2 years ago

syyyr commented 2 years ago

Hi, this kind of module crashes the server

module m {
    include ""
}

Error message is here:

2021-12-03T01:42:30.096 ERROR (pid:341094) [services] - Server languageserver.yang failed to start: ResponseError2: Internal error.
    at handleResponse (/home/vk/.local/share/nvim/site/pack/bundle/opt/coc.nvim/build/index.js:13869:40)
    at processMessageQueue (/home/vk/.local/share/nvim/site/pack/bundle/opt/coc.nvim/build/index.js:13707:13)
    at Immediate.<anonymous> (/home/vk/.local/share/nvim/site/pack/bundle/opt/coc.nvim/build/index.js:13693:11)
    at processImmediate (node:internal/timers:464:21) {
  code: -32603,
  data: 'java.util.concurrent.CompletionException: org.eclipse.emf.common.util.WrappedException: java.lang.IllegalArgumentException: Qualified name cannot be empty\n' +
    '\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:331)\n' +
    '\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:346)\n' +
    '\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:632)\n' +
    '\tat java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)\n' +
    '\tat java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2088)\n' +
    '\tat org.eclipse.xtext.ide.server.concurrent.WriteRequest.run(WriteRequest.java:44)\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:829)\n' +
    'Caused by: org.eclipse.emf.common.util.WrappedException: java.lang.IllegalArgumentException: Qualified name cannot be empty\n' +
    '\tat org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:244)\n' +
    '\tat org.eclipse.xtext.linking.lazy.LazyLinkingResource.doResolveLazyCrossReference(LazyLinkingResource.java:203)\n' +
    '\tat org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReference(LazyLinkingResource.java:162)\n' +
    '\tat org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReferences(LazyLinkingResource.java:148)\n' +
    '\tat org.eclipse.xtext.EcoreUtil2.resolveLazyCrossReferences(EcoreUtil2.java:504)\n' +
    '\tat org.eclipse.xtext.build.IncrementalBuilder$InternalStatefulIncrementalBuilder.lambda$launch$2(IncrementalBuilder.java:265)\n' +
    '\tat com.google.common.collect.Iterators$6.transform(Iterators.java:783)\n' +
    '\tat com.google.common.collect.TransformedIterator.next(TransformedIterator.java:47)\n' +
    '\tat com.google.common.collect.FluentIterable.copyInto(FluentIterable.java:791)\n' +
    '\tat org.eclipse.xtext.build.ClusteringStorageAwareResourceLoader.executeClustered(ClusteringStorageAwareResourceLoader.java:68)\n' +
    '\tat org.eclipse.xtext.build.BuildContext.executeClustered(BuildContext.java:54)\n' +
    '\tat org.eclipse.xtext.build.IncrementalBuilder$InternalStatefulIncrementalBuilder.launch(IncrementalBuilder.java:258)\n' +
    '\tat org.eclipse.xtext.build.IncrementalBuilder.build(IncrementalBuilder.java:403)\n' +
    '\tat org.eclipse.xtext.build.IncrementalBuilder.build(IncrementalBuilder.java:385)\n' +
    '\tat org.eclipse.xtext.ide.server.ProjectManager.doBuild(ProjectManager.java:105)\n' +
    '\tat org.eclipse.xtext.ide.server.ProjectManager.doInitialBuild(ProjectManager.java:96)\n' +
    '\tat org.eclipse.xtext.ide.server.BuildManager.doInitialBuild(BuildManager.java:172)\n' +
    '\tat org.eclipse.xtext.ide.server.WorkspaceManager.refreshWorkspaceConfig(WorkspaceManager.java:172)\n' +
    '\tat org.eclipse.xtext.ide.server.WorkspaceManager.initialize(WorkspaceManager.java:145)\n' +
    '\tat org.eclipse.xtext.ide.server.LanguageServerImpl.lambda$initialize$0(LanguageServerImpl.java:220)\n' +
    '\tat org.eclipse.xtext.ide.server.concurrent.WriteRequest.run(WriteRequest.java:38)\n' +
    '\t... 5 more\n' +
    'Caused by: java.lang.IllegalArgumentException: Qualified name cannot be empty\n' +
    '\tat com.google.common.base.Preconditions.checkArgument(Preconditions.java:142)\n' +
    '\tat org.eclipse.xtext.naming.IQualifiedNameConverter$DefaultImpl.toQualifiedName(IQualifiedNameConverter.java:58)\n' +
    '\tat io.typefox.yang.scoping.Linker.getLinkingName(Linker.java:92)\n' +
    '\tat io.typefox.yang.scoping.Linker.link(Linker.java:47)\n' +
    '\tat io.typefox.yang.scoping.ScopeContextProvider.linkImportedModule(ScopeContextProvider.java:943)\n' +
    '\tat io.typefox.yang.scoping.ScopeContextProvider._computeScope(ScopeContextProvider.java:825)\n' +
    '\tat io.typefox.yang.scoping.ScopeContextProvider.computeScope(ScopeContextProvider.java:1183)\n' +
    '\tat io.typefox.yang.scoping.ScopeContextProvider.handleGeneric(ScopeContextProvider.java:755)\n' +
    '\tat io.typefox.yang.scoping.ScopeContextProvider.getScopeContext(ScopeContextProvider.java:290)\n' +
    '\tat io.typefox.yang.resource.YangResource.getEObject(YangResource.java:33)\n' +
    '\tat org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:236)\n' +
    '\t... 25 more\n'
}
2021-12-03T01:42:31.793 INFO (pid:341094) [attach] - receive notification: showInfo []

By the way, this is a fuzz test for the libyang project - this specific test can be found here https://github.com/CESNET/libyang/tree/master/tests/fuzz/corpus/lys_parse_mem. I think, it may be possible, that the module in this example is not the only module that will crash yang-lsp. By the way, thank you for this project, it really helps me.

dhuebner commented 2 years ago

We should better catch the empty QName case in ScopeContextProvider and don't try to link

dhuebner commented 2 years ago

@syyyr Should be fixed in 0.5.0 nightly