dlang-community / DCD

The D Completion Daemon is an auto-complete program for the D programming language
GNU General Public License v3.0
349 stars 71 forks source link

assertion failure in server when receiving empty files on complete & similar #617

Closed WebFreak001 closed 4 years ago

WebFreak001 commented 4 years ago
./dcd-client -s foo < /dev/null

will trigger (on ~master, works fine on 0.12.0)

core.exception.AssertError@../../.dub/packages/libdparse-0.13.2/libdparse/src/dparse/lexer.d(2319): Assertion failure
----------------
??:? _d_assertp [0x5558133a0d85]
??:? pure nothrow ref @nogc @trusted dparse.lexer.StringCache dparse.lexer.StringCache.__ctor(ulong) [0x55581335231a]
??:? dcd.common.messages.AutocompleteResponse dcd.server.autocomplete.symbols.symbolSearch(const(dcd.common.messages.AutocompleteRequest), ref dsymbol.modulecache.ModuleCache) [0x55581324e939]
??:? int dcd.server.main.runServer(immutable(char)[][]) [0x5558132606f2]
??:? _Dmain [0x55581325f993]

because it tries to create a StringCache with size 0, because optimalBucketCount returns 0 if 0 is passed in as length, which triggers an assert on StringCache.