Pure-D / serve-d

D LSP server (dlang language server protocol server)
MIT License
194 stars 48 forks source link

Tests fail for `:lsp` with `dmd -O` due to a bug in dmd #360

Open the-horo opened 4 months ago

the-horo commented 4 months ago

Reported upstream at: https://issues.dlang.org/show_bug.cgi?id=24406.

$ DFLAGS=-O dub test :lsp --compiler=dmd --build=unittest
     # <snip> #
     Running lsp/serve-d-lsp-test-library
 === Test SOF ===
0 byte -> offset 0
0 byte -> position Position(0, 0)
0 offset -> byte 0
core.exception.AssertError@lsp/source/served/lsp/textdocumentmanager.d(1425): fail SOF offset->byte = 18
----------------
??:? _d_unittest_msg [0x7ff4ef628a24]
lsp/source/served/lsp/textdocumentmanager.d:1426 void served.lsp.textdocumentmanager.__unittest_L1399_C2() [0x563f4c2b155a]
??:? void served.lsp.textdocumentmanager.__modtest() [0x563f4c2d5af1]
??:? int core.runtime.runModuleUnitTests().__foreachbody6(object.ModuleInfo*) [0x7ff4ef62b5aa]
??:? int object.ModuleInfo.opApply(scope int delegate(object.ModuleInfo*)).__lambda2(immutable(object.ModuleInfo*)) [0x7ff4ef60f457]
??:? int rt.minfo.moduleinfos_apply(scope int delegate(immutable(object.ModuleInfo*))).__foreachbody2(ref rt.sections_elf_shared.DSO) [0x7ff4ef66e77b]
??:? int rt.sections_elf_shared.DSO.opApply(scope int delegate(ref rt.sections_elf_shared.DSO)) [0x7ff4ef670133]
??:? int rt.minfo.moduleinfos_apply(scope int delegate(immutable(object.ModuleInfo*))) [0x7ff4ef66e709]
??:? int object.ModuleInfo.opApply(scope int delegate(object.ModuleInfo*)) [0x7ff4ef60f429]
??:? runModuleUnitTests [0x7ff4ef62b3df]
??:? void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll() [0x7ff4ef666758]
??:? void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x7ff4ef6666e5]
??:? _d_run_main2 [0x7ff4ef66664e]
??:? _d_run_main [0x7ff4ef666437]
/usr/lib/dmd/2.107/import/core/internal/entrypoint.d:29 main [0x563f4c204181]
??:? [0x7ff4eef3cee9]
??:? __libc_start_main [0x7ff4eef3cfa4]
??:? _start [0x563f4c203130]
1/3 modules FAILED unittests
Error Program exited with code 1

I though it would be good to report this here in case somebody else hits it.

WebFreak001 commented 4 months ago

thanks for investigating and reporting the issue! The code there is very micro optimized, it may make sense to just make it a bit more readable, but on the other hand it has worked for a while. Maybe serve-d would be a good candidate to add to the D auto-tester

the-horo commented 4 months ago

In the end this is a bug in dmd so no need to change the code, it's my view at least. I did just debug some of it and I wouldn't say it that unreadable, though, admittedly, the failing test case is the simple one with all zeros.