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

Bug: LSP crashes in CLion with the following LUA code #11

Open
motor-dev opened this issue Dec 6, 2024 · 14 comments
Open

Bug: LSP crashes in CLion with the following LUA code #11

motor-dev opened this issue Dec 6, 2024 · 14 comments

Comments

@motor-dev
Copy link

motor-dev commented Dec 6, 2024

EmmyLua2 0.7.1.28-IDEA242
LSP4j 8.1.0

The following code in a LUA file crashes the LSP plugin when the file is open in the editor

---@class X
---@field  [string] any
local X

---@class Y : X
local Y

function Y:doStuff()
end

the whole combination that makes it crash are:

  • class X has an __index/setindex metamethod described with @field [string] any
  • class Y inherits from X
  • a method is bound to Y

I get two different stacktraces:

Error while consuming 'textDocument/inlayHint' with language server 'EmmyLua'

org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Object reference not set to an instance of an object.
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
	at com.redhat.devtools.lsp4ij.LanguageServerWrapper.lambda$start$4(LanguageServerWrapper.java:314)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1491)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:2073)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2035)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)

and

Error while initializing ProjectIndexingDumbAndScanningStrategy

java.lang.IllegalStateException: Recursive update
	at java.base/java.util.concurrent.ConcurrentHashMap.replaceNode(ConcurrentHashMap.java:1167)
	at java.base/java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:1102)
	at com.intellij.util.messages.impl.MessageBusImpl.notifyOnSubscription$intellij_platform_core(MessageBusImpl.kt:250)
	at com.intellij.util.messages.impl.BaseBusConnection.subscribe(BaseBusConnection.kt:39)
	at com.redhat.devtools.lsp4ij.client.indexing.ProjectIndexingDumbAndScanningStrategy.initialize(ProjectIndexingDumbAndScanningStrategy.java:104)
	at com.redhat.devtools.lsp4ij.client.indexing.ProjectIndexingDumbAndScanningStrategy.<init>(ProjectIndexingDumbAndScanningStrategy.java:57)
	at com.intellij.platform.instanceContainer.instantiation.InstantiateKt.instantiate$lambda$0(instantiate.kt:46)
	at com.intellij.platform.instanceContainer.instantiation.InstantiateKt.instantiate$lambda$8$lambda$7(instantiate.kt:310)
	at com.intellij.platform.instanceContainer.instantiation.InstantiateKt.withStoredTemporaryContext(instantiate.kt:328)
	at com.intellij.platform.instanceContainer.instantiation.InstantiateKt.instantiate(instantiate.kt:309)
	at com.intellij.platform.instanceContainer.instantiation.InstantiateKt.instantiate(instantiate.kt:43)
	at com.intellij.serviceContainer.ServiceInstanceInitializer.createInstance$suspendImpl(ServiceInstanceInitializer.kt:30)
	at com.intellij.serviceContainer.ServiceInstanceInitializer.createInstance(ServiceInstanceInitializer.kt)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder$initialize$1$1.invokeSuspend(LazyInstanceHolder.kt:163)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder$initialize$1$1.invoke(LazyInstanceHolder.kt)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder$initialize$1$1.invoke(LazyInstanceHolder.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:62)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:163)
	at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder$initialize$1.invokeSuspend(LazyInstanceHolder.kt:161)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder$initialize$1.invoke(LazyInstanceHolder.kt)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder$initialize$1.invoke(LazyInstanceHolder.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:27)
	at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:90)
	at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:123)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:52)
	at kotlinx.coroutines.BuildersKt.launch(Unknown Source)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder.initialize(LazyInstanceHolder.kt:146)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder.access$initialize(LazyInstanceHolder.kt:14)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder.tryInitialize(LazyInstanceHolder.kt:136)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder.getInstance(LazyInstanceHolder.kt:96)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder.getInstanceInCallerContext$suspendImpl(LazyInstanceHolder.kt:88)
	at com.intellij.platform.instanceContainer.internal.LazyInstanceHolder.getInstanceInCallerContext(LazyInstanceHolder.kt)
	at com.intellij.serviceContainer.ComponentManagerImplKt$doGetOrCreateInstanceBlocking$1.invokeSuspend(ComponentManagerImpl.kt:1566)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:277)
	at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:111)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$BuildersKt__BuildersKt(Builders.kt:84)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:52)
	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
	at com.intellij.serviceContainer.ComponentManagerImplKt.runBlockingInitialization$lambda$10(ComponentManagerImpl.kt:1684)
	at com.intellij.openapi.progress.ContextKt.prepareThreadContext(context.kt:82)
	at com.intellij.serviceContainer.ComponentManagerImplKt.runBlockingInitialization(ComponentManagerImpl.kt:1675)
	at com.intellij.serviceContainer.ComponentManagerImplKt.doGetOrCreateInstanceBlocking(ComponentManagerImpl.kt:1565)
	at com.intellij.serviceContainer.ComponentManagerImplKt.getOrCreateInstanceBlocking(ComponentManagerImpl.kt:1560)
	at com.intellij.serviceContainer.ComponentManagerImpl.doGetService(ComponentManagerImpl.kt:751)
	at com.intellij.serviceContainer.ComponentManagerImpl.getService(ComponentManagerImpl.kt:695)
	at com.redhat.devtools.lsp4ij.client.indexing.ProjectIndexingDumbAndScanningStrategy.getInstance(ProjectIndexingDumbAndScanningStrategy.java:61)
	at com.redhat.devtools.lsp4ij.client.indexing.ProjectIndexingAppLifecycleListener.<init>(ProjectIndexingAppLifecycleListener.java:36)
	at com.intellij.serviceContainer.ComponentManagerImpl.findConstructorAndInstantiateClass(ComponentManagerImpl.kt:909)
	at com.intellij.serviceContainer.ComponentManagerImpl.doInstantiateClass(ComponentManagerImpl.kt:918)
	at com.intellij.serviceContainer.ComponentManagerImpl.instantiateClass(ComponentManagerImpl.kt:903)
	at com.intellij.serviceContainer.ComponentManagerImpl.createListener(ComponentManagerImpl.kt:965)
	at com.intellij.util.messages.impl.CompositeMessageBus.subscribeLazyListeners$lambda$4(CompositeMessageBus.kt:123)
	at com.intellij.openapi.progress.Cancellation.computeInNonCancelableSection(Cancellation.java:114)
	at com.intellij.util.messages.impl.CompositeMessageBus.subscribeLazyListeners(CompositeMessageBus.kt:117)
	at com.intellij.util.messages.impl.CompositeMessageBus.doComputeSubscribers$intellij_platform_core(CompositeMessageBus.kt:93)
	at com.intellij.util.messages.impl.MessageBusImpl.computeSubscribers$intellij_platform_core(MessageBusImpl.kt:243)
	at com.intellij.util.messages.impl.CompositeMessageBus.computeSubscribers$intellij_platform_core(CompositeMessageBus.kt:88)
	at com.intellij.util.messages.impl.ToDirectChildrenMessagePublisher$publish$handlers$1.invoke(CompositeMessageBus.kt:279)
	at com.intellij.util.messages.impl.ToDirectChildrenMessagePublisher$publish$handlers$1.invoke(CompositeMessageBus.kt:279)
	at com.intellij.util.messages.impl.ToDirectChildrenMessagePublisher.publish$lambda$0(CompositeMessageBus.kt:279)
	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
	at com.intellij.util.messages.impl.ToDirectChildrenMessagePublisher.publish$intellij_platform_core(CompositeMessageBus.kt:279)
	at com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:490)
	at jdk.proxy2/jdk.proxy2.$Proxy35.appFrameCreated(Unknown Source)
	at com.intellij.idea.IdeStarter$openProjectIfNeeded$isOpenProjectNeeded$1$1.invokeSuspend(IdeStarter.kt:123)
	at com.intellij.idea.IdeStarter$openProjectIfNeeded$isOpenProjectNeeded$1$1.invoke(IdeStarter.kt)
	at com.intellij.idea.IdeStarter$openProjectIfNeeded$isOpenProjectNeeded$1$1.invoke(IdeStarter.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:62)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:163)
	at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
	at com.intellij.platform.diagnostic.telemetry.impl.TracerKt.span(tracer.kt:56)
	at com.intellij.platform.diagnostic.telemetry.impl.TracerKt.span$default(tracer.kt:48)
	at com.intellij.idea.IdeStarter$openProjectIfNeeded$isOpenProjectNeeded$1.invokeSuspend(IdeStarter.kt:121)
	at com.intellij.idea.IdeStarter$openProjectIfNeeded$isOpenProjectNeeded$1.invoke(IdeStarter.kt)
	at com.intellij.idea.IdeStarter$openProjectIfNeeded$isOpenProjectNeeded$1.invoke(IdeStarter.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:62)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:163)
	at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
	at com.intellij.platform.diagnostic.telemetry.impl.TracerKt.span(tracer.kt:56)
	at com.intellij.platform.diagnostic.telemetry.impl.TracerKt.span$default(tracer.kt:48)
	at com.intellij.idea.IdeStarter.openProjectIfNeeded$suspendImpl(IdeStarter.kt:120)
	at com.intellij.idea.IdeStarter.openProjectIfNeeded(IdeStarter.kt)
	at com.intellij.idea.IdeStarter$start$2$openProjectBlock$1.invokeSuspend(IdeStarter.kt:81)
	at com.intellij.idea.IdeStarter$start$2$openProjectBlock$1.invoke(IdeStarter.kt)
	at com.intellij.idea.IdeStarter$start$2$openProjectBlock$1.invoke(IdeStarter.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:62)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:163)
	at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
	at com.intellij.idea.IdeStarter$start$2.invokeSuspend(IdeStarter.kt:94)
	at com.intellij.idea.IdeStarter$start$2.invoke(IdeStarter.kt)
	at com.intellij.idea.IdeStarter$start$2.invoke(IdeStarter.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:62)
	at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:261)
	at com.intellij.idea.IdeStarter.start$suspendImpl(IdeStarter.kt:66)
	at com.intellij.idea.IdeStarter.start(IdeStarter.kt)
	at com.intellij.platform.ide.bootstrap.ApplicationLoader$executeApplicationStarter$2.invokeSuspend(ApplicationLoader.kt:438)
	at com.intellij.platform.ide.bootstrap.ApplicationLoader$executeApplicationStarter$2.invoke(ApplicationLoader.kt)
	at com.intellij.platform.ide.bootstrap.ApplicationLoader$executeApplicationStarter$2.invoke(ApplicationLoader.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:62)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:163)
	at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
	at com.intellij.platform.diagnostic.telemetry.impl.TracerKt.span(tracer.kt:56)
	at com.intellij.platform.diagnostic.telemetry.impl.TracerKt.span$default(tracer.kt:48)
	at com.intellij.platform.ide.bootstrap.ApplicationLoader.executeApplicationStarter(ApplicationLoader.kt:437)
	at com.intellij.platform.ide.bootstrap.StartupUtil$startApplication$9.invokeSuspend(startup.kt:318)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:608)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:873)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:763)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:750)
@angelozerr
Copy link

@motor-dev could you please install https://github.com/redhat-developer/lsp4ij?tab=readme-ov-file#testing-nightly-builds and tell me if it is working better? I have tried to fix it but as Icannot reproduce it it ishard to know if the fix is correct. Thanks for your feedback.

@motor-dev
Copy link
Author

motor-dev commented Dec 7, 2024

LSP4ij 0.8.2-20241207-172221 [edit] one of the errors disappeared, the other one remains:

Error while consuming 'textDocument/inlayHint' with language server 'EmmyLua'

org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Object reference not set to an instance of an object.
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
	at com.redhat.devtools.lsp4ij.LanguageServerWrapper.lambda$start$4(LanguageServerWrapper.java:314)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1491)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:2073)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2035)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)

@motor-dev
Copy link
Author

I have reverted to version 0.8.1 and tested again, and got again the callstack mentioned at the top (java.lang.IllegalStateException: Recursive update). So the update to the nightly build seems to have fixed that part.

@angelozerr
Copy link

I have reverted to version 0.8.1 and tested again, and got again the callstack mentioned at the top (java.lang.IllegalStateException: Recursive update). So the update to the nightly build seems to have fixed that part.

Thanks @motor-dev for your feedback. The fix that I have tried to do was for this IllegalStateException problem. That is great that my fix is working.

For the other error, I dont know how to reproduce it? Have you every time this error znd you dont see inlay hints? If you update the editor content do you see inlay hints?

@angelozerr
Copy link

@motor-dev have you this problem with 0.70 LSP4IJ version, 0.6.0 ?

@motor-dev
Copy link
Author

motor-dev commented Dec 8, 2024

I create a new file test.lua in CLion and I copy-paste the content that I mentioned in the initial post in it. As soon as it is pasted I get an error report in CLion with the stacktrace above. Inlay hints are missing and some code completion in other files is not working. This is the result:
image

If I change one of the things that I mentioned at the top (I remove inheritance, I remove the ---@field [string] any annotation, or I remove the function) then I have better hints/core completion. Here I moved the function from the Y to the X class:
image

@angelozerr
Copy link

Thanks for your feedback.

Could you share your full stack trace please.

I suspect the problem comes from lua language server.

@motor-dev
Copy link
Author

I am afraid the full stacktrace is very short

Error while consuming 'textDocument/inlayHint' with language server 'EmmyLua'

org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Object reference not set to an instance of an object.
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
	at com.redhat.devtools.lsp4ij.LanguageServerWrapper.lambda$start$4(LanguageServerWrapper.java:314)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1491)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:2073)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2035)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)

@angelozerr
Copy link

@CppCXY I suspect that error comes from your language server, right?

@angelozerr
Copy link

@motor-dev I suspect that error comes from lua language server. The strange thing is that error should zppear in a notif popup

@CppCXY
Copy link
Member

CppCXY commented Dec 8, 2024

It is indeed an error of my language server.
I got this in vscode:

System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0x117
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.GetMemberAndWriteJson(Object, WriteStack&, Utf8JsonWriter) + 0x1a6
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite(Utf8JsonWriter, T, JsonSerializerOptions, WriteStack&) + 0x337
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0x90
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0x175
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.GetMemberAndWriteJson(Object, WriteStack&, Utf8JsonWriter) + 0x143
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite(Utf8JsonWriter, T, JsonSerializerOptions, WriteStack&) + 0x313
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0x141
   at System.Text.Json.Serialization.Converters.ListOfTConverter`2.OnWriteResume(Utf8JsonWriter, TCollection, JsonSerializerOptions, WriteStack&) + 0xe5
   at System.Text.Json.Serialization.JsonCollectionConverter`2.OnTryWrite(Utf8JsonWriter, TCollection, JsonSerializerOptions, WriteStack&) + 0xe7
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0x141
   at System.Text.Json.Serialization.JsonConverter`1.WriteCore(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0xf1
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Serialize(Utf8JsonWriter, T&, Object) + 0xb6
   at EmmyLua.LanguageServer.Framework.Protocol.Model.Union.StringOrJsonConverter`1.Write(Utf8JsonWriter, StringOr`1, JsonSerializerOptions) + 0x70
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0x202
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.GetMemberAndWriteJson(Object, WriteStack&, Utf8JsonWriter) + 0x217
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite(Utf8JsonWriter, T, JsonSerializerOptions, WriteStack&) + 0x313
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0x141
   at System.Text.Json.Serialization.Converters.ListOfTConverter`2.OnWriteResume(Utf8JsonWriter, TCollection, JsonSerializerOptions, WriteStack&) + 0xe5
   at System.Text.Json.Serialization.JsonCollectionConverter`2.OnTryWrite(Utf8JsonWriter, TCollection, JsonSerializerOptions, WriteStack&) + 0xe7
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0x141
   at System.Text.Json.Serialization.JsonConverter`1.WriteCore(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0xf1
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Serialize(Utf8JsonWriter, T&, Object) + 0xb6
   at EmmyLua.LanguageServer.Framework.Protocol.Message.InlayHint.InlayHintResponseJsonConverter.Write(Utf8JsonWriter, InlayHintResponse, JsonSerializerOptions) + 0xbb
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0x202
   at System.Text.Json.Serialization.JsonConverter`1.WriteCore(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0xf1
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Serialize(Utf8JsonWriter, T&, Object) + 0xb6
   at System.Text.Json.JsonSerializer.WriteDocument[TValue](TValue&, JsonTypeInfo`1) + 0x90
   at EmmyLua.LanguageServer.Framework.Server.Handler.InlayHintHandlerBase.<>c__DisplayClass2_0.<<RegisterHandler>b__0>d.MoveNext() + 0xfd
--- End of stack trace from previous location ---
   at EmmyLua.LanguageServer.Framework.Server.LanguageServer.<OnDispatch>d__59.MoveNext() + 0x4cb

@angelozerr
Copy link

It is indeed an error of my language server.
I got this in vscode:

System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0x117
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.GetMemberAndWriteJson(Object, WriteStack&, Utf8JsonWriter) + 0x1a6
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite(Utf8JsonWriter, T, JsonSerializerOptions, WriteStack&) + 0x337
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0x90
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0x175
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.GetMemberAndWriteJson(Object, WriteStack&, Utf8JsonWriter) + 0x143
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite(Utf8JsonWriter, T, JsonSerializerOptions, WriteStack&) + 0x313
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0x141
   at System.Text.Json.Serialization.Converters.ListOfTConverter`2.OnWriteResume(Utf8JsonWriter, TCollection, JsonSerializerOptions, WriteStack&) + 0xe5
   at System.Text.Json.Serialization.JsonCollectionConverter`2.OnTryWrite(Utf8JsonWriter, TCollection, JsonSerializerOptions, WriteStack&) + 0xe7
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0x141
   at System.Text.Json.Serialization.JsonConverter`1.WriteCore(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0xf1
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Serialize(Utf8JsonWriter, T&, Object) + 0xb6
   at EmmyLua.LanguageServer.Framework.Protocol.Model.Union.StringOrJsonConverter`1.Write(Utf8JsonWriter, StringOr`1, JsonSerializerOptions) + 0x70
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0x202
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.GetMemberAndWriteJson(Object, WriteStack&, Utf8JsonWriter) + 0x217
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite(Utf8JsonWriter, T, JsonSerializerOptions, WriteStack&) + 0x313
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0x141
   at System.Text.Json.Serialization.Converters.ListOfTConverter`2.OnWriteResume(Utf8JsonWriter, TCollection, JsonSerializerOptions, WriteStack&) + 0xe5
   at System.Text.Json.Serialization.JsonCollectionConverter`2.OnTryWrite(Utf8JsonWriter, TCollection, JsonSerializerOptions, WriteStack&) + 0xe7
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0x141
   at System.Text.Json.Serialization.JsonConverter`1.WriteCore(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0xf1
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Serialize(Utf8JsonWriter, T&, Object) + 0xb6
   at EmmyLua.LanguageServer.Framework.Protocol.Message.InlayHint.InlayHintResponseJsonConverter.Write(Utf8JsonWriter, InlayHintResponse, JsonSerializerOptions) + 0xbb
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0x202
   at System.Text.Json.Serialization.JsonConverter`1.WriteCore(Utf8JsonWriter, T&, JsonSerializerOptions, WriteStack&) + 0xf1
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Serialize(Utf8JsonWriter, T&, Object) + 0xb6
   at System.Text.Json.JsonSerializer.WriteDocument[TValue](TValue&, JsonTypeInfo`1) + 0x90
   at EmmyLua.LanguageServer.Framework.Server.Handler.InlayHintHandlerBase.<>c__DisplayClass2_0.<<RegisterHandler>b__0>d.MoveNext() + 0xfd
--- End of stack trace from previous location ---
   at EmmyLua.LanguageServer.Framework.Server.LanguageServer.<OnDispatch>d__59.MoveNext() + 0x4cb

Ok thanks @CppCXY but I dont understand why this error appears in the log. It should appear by default in error popup. @motor-dev have you configured that?

@motor-dev
Copy link
Author

motor-dev commented Dec 8, 2024

apologies for the confusion, I think I misunderstood what happens in CLion.
I do get an error popop, but I thought the language server completely stopped working because the error popup from CLion is much more alarming than what actually happens:
image

from the description/stacktrace it lead me to think that the plugin had crashed (and that I should disable it) but in reality it looks like the language server is still running and working except for code defined in the file that generates the issue, so the severity of the problem vs what's reported by CLion doesn't really match.

And just to be clear, I thought the language server had crashed inside of CLion, but Clion itself does not crash.

@CppCXY
Copy link
Member

CppCXY commented Dec 8, 2024

I will check what's going on tomorrow. I have been rewriting the language server in Rust recently, so I haven't had much time for the old language server.

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

No branches or pull requests

3 participants