<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63717>63717</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mojo-parser] Crash when the LSP parses a file
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
walter-erquinigo
</td>
</tr>
</table>
<pre>
Repro:
Just open KGEN/test/parse-mojo/statements.mojo on VSCode with the lsp enabled. Then the following crash happens in the parser. It seems not to be caused by the LSP.
Assertion failed: (detail::isPresent(Val) && "dyn_cast on a non-existent value"), function dyn_cast, file Casting.h, line 650.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /Users/walter/Source/modular/.derived/build/bin/mojo-lsp-server
1. Program arguments: /Users/walter/Source/modular/.derived/build/bin/mojo-lsp-server
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 mojo-lsp-server 0x00000001022c475c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 mojo-lsp-server 0x00000001022c29f8 llvm::sys::RunSignalHandlers() + 112
2 mojo-lsp-server 0x00000001022c4de4 SignalHandler(int) + 344
3 libsystem_platform.dylib 0x00000001a5e9aa24 _sigtramp + 56
4 libsystem_pthread.dylib 0x00000001a5e6bc28 pthread_kill + 288
5 libsystem_c.dylib 0x00000001a5d79ae8 abort + 180
6 libsystem_c.dylib 0x00000001a5d78e44 err + 0
7 mojo-lsp-server 0x0000000102668d5c M::KGEN::LIT::ASTType::getRegisterPassability(llvm::SMLoc, M::KGEN::LIT::SharedState&) const (.cold.2) + 0
8 mojo-lsp-server 0x00000001022c5f14 M::KGEN::LIT::ASTType::getRegisterPassability(llvm::SMLoc, M::KGEN::LIT::SharedState&) const + 236
9 mojo-lsp-server 0x00000001022c5f4c M::KGEN::LIT::ASTType::isRegisterPassable(llvm::SMLoc, M::KGEN::LIT::SharedState&) const + 12
10 mojo-lsp-server 0x000000010231df4c (anonymous namespace)::StmtParser::parseSuite(long)::$_1::operator()(bool, unsigned long) const + 6888
11 mojo-lsp-server 0x000000010231c0e0 (anonymous namespace)::StmtParser::parseSuite(long) + 92
12 mojo-lsp-server 0x000000010231bf8c M::KGEN::LIT::ParserBase::parseSuite(M::KGEN::LIT::ASTDecl&, M::KGEN::LIT::Lexer&) + 56
13 mojo-lsp-server 0x00000001022dfbac M::KGEN::LIT::DeclResolver::resolveBody(M::KGEN::LIT::FuncOp, M::KGEN::LIT::Lexer&, M::KGEN::LIT::ASTDecl&) + 1676
14 mojo-lsp-server 0x00000001022d9970 M::KGEN::LIT::DeclResolver::resolve(M::KGEN::LIT::ASTDecl&, M::KGEN::LIT::DeclResolvedness, llvm::SMLoc) + 1228
15 mojo-lsp-server 0x00000001022d8ce0 M::KGEN::LIT::DeclResolver::resolveAllReferencedFrom(M::KGEN::LIT::ASTDecl&) + 224
16 mojo-lsp-server 0x0000000102317f24 M::MojoParserContext::parseFile(unsigned int) + 404
17 mojo-lsp-server 0x000000010225409c (anonymous namespace)::MojoDocument::initialize(mlir::lsp::URIForFile const&, std::__1::vector<mlir::lsp::Diagnostic, std::__1::allocator<mlir::lsp::Diagnostic>>&) + 760
18 mojo-lsp-server 0x0000000102253b60 M::KGEN::LIT::MojoServer::addDocument(mlir::lsp::URIForFile const&, llvm::StringRef, long long, std::__1::vector<mlir::lsp::Diagnostic, std::__1::allocator<mlir::lsp::Diagnostic>>&) + 504
19 mojo-lsp-server 0x000000010224d920 (anonymous namespace)::LSPServer::onDocumentDidOpen(mlir::lsp::DidOpenTextDocumentParams const&) + 164
20 mojo-lsp-server 0x00000001022515b8 void llvm::detail::UniqueFunctionBase<void, llvm::json::Value>::CallImpl<void mlir::lsp::MessageHandler::notification<mlir::lsp::DidOpenTextDocumentParams, (anonymous namespace)::LSPServer>(llvm::StringLiteral, (anonymous namespace)::LSPServer*, void ((anonymous namespace)::LSPServer::*)(mlir::lsp::DidOpenTextDocumentParams const&))::'lambda'(llvm::json::Value)>(void*, llvm::json::Value&) + 132
21 mojo-lsp-server 0x000000010233dc04 mlir::lsp::MessageHandler::onNotify(llvm::StringRef, llvm::json::Value) + 284
22 mojo-lsp-server 0x000000010233fcc0 mlir::lsp::JSONTransport::handleMessage(llvm::json::Value, mlir::lsp::MessageHandler&) + 636
23 mojo-lsp-server 0x000000010233f8d0 mlir::lsp::JSONTransport::run(mlir::lsp::MessageHandler&) + 384
24 mojo-lsp-server 0x000000010224ca98 M::KGEN::LIT::runMojoLSPServer(M::KGEN::LIT::MojoServer&, mlir::lsp::JSONTransport&) + 2136
25 mojo-lsp-server 0x000000010225e980 main + 1212
26 dyld 0x00000001a5b13f28 start + 2236
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWN1u2zoSfhrlhoghUbJ-LnzhOPGennVaI04L7N4ElDiW2VKkDkml8T79gqTk2I1ju91icYwglmhy5ptvhjNDEq1ZLQAmwfgmGN9ekc5spJp8J9yAugb1V8cEq-VVKel28gCtkkE8DcLbIJz-2WmDZAsC_fMfdx8DPDegTYDnLVEarhv5VQZ4rg0x0IAwemRHkBToy2omKaDvzGyQ2QDiukUgSMmBjtDjBoQbXUvO5XcmalQpojdoQ9oWhEbM_-yUqBH6YJAGaDQS0iAjUQmoIp0Gisqtm7hYLUcer_8_1RqUYVKgNWEcaBBPUYBzCoYwbm2Lp0wvFWgQJsD5F8IDXKAApwFOUYAx3YqniljLBSJISHENL0wbEAY9E95BgHGAiwDP0LoTlVM0LHGDjAOaEW2YqEcbO8KZAJSOwx7lcnE3Xd0h3ZUNM4igsquRglYqZ97GmFZblHge4HnNzKYrR5VsAjzn_Hn4um6V_AqVdQbTugMd4DkigiImKt5RcMR4WktSfTOKVNCrXxlSfUO0a9qdny2yYqlkrUiDiKo7507P2_yzBmXF-4AJ8HwlO1VBgOeNpB0ndmhEQb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