d-language-server / dls

A Language Server implementation for D
http://dls.dub.pm
106 stars 15 forks source link

Crash on string of cyrillic characters #33

Closed BorisCarvajal closed 5 years ago

BorisCarvajal commented 5 years ago

Reading a file with this code crash the server:

auto b = func("дфкчлсрт") == 12345;

If I remove one char of the string or one digit to the number, there's no crash.

Also I'm using Emacs and "UTF-8".

core.exception.AssertError@/opt/dmd-2.084/import/std/utf.d(447): Past the end of the UTF-16 sequence
----------------
??:? _d_assert_msg [0x78d7230c]
/opt/dmd-2.084/import/std/utf.d:447 pure nothrow @nogc @safe uint std.utf.stride!(const(wchar)[]).stride(ref const(wchar)[], ulong) [0x6e8d1e4d]
/opt/dmd-2.084/import/std/utf.d:992 pure @safe ulong std.utf.toUCSindex!(wchar).toUCSindex(const(wchar)[], ulong) [0x6e8d1d84]
/home/boris/.dub/packages/dls-0.22.3/dls/util/source/dls/util/document.d:213 const dls.protocol.definitions.Range dls.util.document.Document.wordRangeAtLineAndByte(ulong, ulong) [0x6e8c0879]
/home/boris/.dub/packages/dls-0.22.3/dls/source/dls/tools/analysis_tool.d:218 dls.protocol.definitions.Diagnostic[] dls.tools.analysis_tool.AnalysisTool.diagnostics(const(dls.util.uri.Uri)) [0x6e7d367a]
/home/boris/.dub/packages/dls-0.22.3/dls/source/dls/protocol/messages/text_document.d:92 void dls.protocol.messages.text_document.didSave(dls.protocol.interfaces.text_document.DidSaveTextDocumentParams) [0x6e7c9ea9]
/home/boris/.dub/packages/dls-0.22.3/dls/source/dls/protocol/handlers.d:75 void dls.protocol.handlers.pushHandler!(void function(dls.protocol.interfaces.text_document.DidSaveTextDocumentParams)*).pushHandler(const(immutable(char)[]), void function(dls.protocol.interfaces.text_document.DidSaveTextDocumentParams)*).__lambda3(std.typecons.Nullable!(std.json.JSONValue).Nullable) [0x6e75eb84]
/home/boris/.dub/packages/dls-0.22.3/dls/source/dls/server.d:266 void dls.server.Server.handleJSON(const(char[])).findAndExecuteHandler() [0x6e7ce4b7]
/home/boris/.dub/packages/dls-0.22.3/dls/source/dls/server.d:328 void dls.server.Server.handleJSON(const(char[])) [0x6e7ce053]
/home/boris/.dub/packages/dls-0.22.3/dls/source/dls/server.d:178 void dls.server.Server.loop().__lambda1() [0x6e7cde1f]
??:? void core.thread.Fiber.run() [0x78d76e93]
??:? fiber_entryPoint [0x78d7626e]
??:? [0xffffffff]
LaurentTreguier commented 5 years ago

It should be fixed in v0.22.5; I also fixed the word range detection for symbol highlighting and such (it only detected ascii characters and _)