zed
zed copied to clipboard
Zed crashes if it can't load a grammar
I've been trying to implement a odin language support extension but Zed crashes when I add the language files (I followed other extension implementations). I tried to install the zed-sql extension myself and that crashes too.
The crash happens when I add any of the language files (highlights.scm
, etc.). Zed successfully detects .odin
suffixed files and tries to use my extension. I think it just can't load the grammar. The unwraps inside grammar_mut()
panic (here).
After I add the line grammar = "odin"
to the languages/odin/config.toml
, the language detection fails, even if I choose it myself from the list.
I suspect I might have did something wrong while building the grammars, but it could be better if the documentation or editor pointed me in the right direction.
Here is the content of the log:
2024-03-03T12:00:45+01:00 [ERROR] {
"thread": "<unnamed>",
"payload": "called `Option::unwrap()` on a `None` value",
"location_data": {
"file": "crates/language/src/language.rs",
"line": 1071
},
"backtrace": [
"<backtrace::capture::Backtrace>::create",
"<backtrace::capture::Backtrace>::new",
"Zed::init_panic_hook::{closure#0}",
"std::panicking::rust_panic_with_hook",
"std::panicking::begin_panic_handler::{{closure}}",
"std::sys_common::backtrace::__rust_end_short_backtrace",
"_rust_begin_unwind",
"core::panicking::panic_fmt",
"core::panicking::panic",
"<language::Language>::with_highlights_query",
"<language::Language>::with_queries",
"<language::language_registry::LanguageRegistry>::get_or_load_language::<<language::language_registry::LanguageRegistry>::language_for_file::{closure#1}>::{closure#2}",
"<async_task::raw::RawTask<core::pin::Pin<alloc::boxed::Box<dyn core::future::future::Future<Output = ()> + core::marker::Send>>, (), <gpui::executor::BackgroundExecutor>::spawn_internal<()>::{closure#0}, ()>>::run",
"_pthread_self"
],
"app_version": "0.124.8",
"release_channel": "Zed",
"os_name": "macOS",
"os_version": "14.1.1",
"architecture": "aarch64",
"panicked_on": 1709463645088,
"installation_id": "b1e3e4c7-c1d7-4f88-8558-a6c52548ac6b",
"session_id": "7ead37e7-64e8-4ceb-92d0-5f4863cb528e"
}
Moving this to the main Zed issue tracker.
We’ve fixed several instances of this over the last few weeks. Closing for now but please reopen if you can still crash zed with a bad grammar.