New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dart extension crash #10352
Comments
Same problem here. To disable the failing extension just remove the part bellow from the file
EnvironmentZed: Zed 0.129.2 |
@flukejones Do you see the same crash if you install the Dart extension using "Install Dev Extension" and pointing to |
For anyone who is experiencing this crash (@flukejones, @pedrosoares) could you share the content of the following file?
From the panic, it looks like the installed wasm file is somehow invalid. I'm curious if I can reproduce the problem if I have the same wasm file as you. |
Ok, never mind, we have found a way of reproducing the bug, by truncating a WASM file at a certain position. |
@maxbrunsfeld I did a build from master (26299fb) and error log was the fallowing:
I did head and tail this file Head
Tail
My internet connection it is unstable currently, probably downloaded the file partialy? |
We opened a Wasmtime issue for this bug, and have added a workaround for it in Zed. bytecodealliance/wasmtime#8322 |
In the meantime, you should try reinstalling the Dart extension. It looks like your download was partially corrupted. |
This PR fixes a potential panic that could occur when loading malformed Wasm files. We now use the `parse_wasm_extension_version` function that was previously used just to extract the Zed extension API version from the Wasm bytes as a pre-validation step. By parsing the entirety of the Wasm file here instead of returning as soon as we find the version, the invalid Wasm bytes are now surfaced as an `Err` instead of a panic. We were able to replicate the panic using the following test: ```rs #[gpui::test] async fn test_bad_wasm(cx: &mut TestAppContext) { init_test(cx); let wasm_host = cx.update(|cx| { WasmHost::new( FakeFs::new(cx.background_executor().clone()), FakeHttpClient::with_200_response(), FakeNodeRuntime::new(), Arc::new(LanguageRegistry::test(cx.background_executor().clone())), PathBuf::from("/the/work/dir".to_string()), cx, ) }); let mut wasm_bytes = std::fs::read("/Users/maxdeviant/Library/Application Support/Zed/extensions/installed/dart/extension.wasm").unwrap(); // This is the error message we were seeing in the stack trace: // range end index 267037 out of range for slice of length 253952 dbg!(&wasm_bytes.len()); // Truncate the bytes to the same point: wasm_bytes.truncate(253952); std::fs::write("/tmp/bad-extension.wasm", wasm_bytes.clone()).unwrap(); let manifest = Arc::new(ExtensionManifest { id: "the-extension".into(), name: "The Extension".into(), version: "0.0.1".into(), schema_version: SchemaVersion(1), description: Default::default(), repository: Default::default(), authors: Default::default(), lib: LibManifestEntry { kind: None, version: None, }, themes: Default::default(), languages: Default::default(), grammars: Default::default(), language_servers: Default::default(), }); // 💥 let result = wasm_host .load_extension(wasm_bytes, manifest, cx.executor()) .await; dbg!(result.map(|_| ())); ``` Release Notes: - Fixed a crash that could occur when loading malformed Wasm extensions ([#10352](#10352)). --------- Co-authored-by: Max <max@zed.dev>
This PR fixes a potential panic that could occur when loading malformed Wasm files. We now use the `parse_wasm_extension_version` function that was previously used just to extract the Zed extension API version from the Wasm bytes as a pre-validation step. By parsing the entirety of the Wasm file here instead of returning as soon as we find the version, the invalid Wasm bytes are now surfaced as an `Err` instead of a panic. We were able to replicate the panic using the following test: ```rs #[gpui::test] async fn test_bad_wasm(cx: &mut TestAppContext) { init_test(cx); let wasm_host = cx.update(|cx| { WasmHost::new( FakeFs::new(cx.background_executor().clone()), FakeHttpClient::with_200_response(), FakeNodeRuntime::new(), Arc::new(LanguageRegistry::test(cx.background_executor().clone())), PathBuf::from("/the/work/dir".to_string()), cx, ) }); let mut wasm_bytes = std::fs::read("/Users/maxdeviant/Library/Application Support/Zed/extensions/installed/dart/extension.wasm").unwrap(); // This is the error message we were seeing in the stack trace: // range end index 267037 out of range for slice of length 253952 dbg!(&wasm_bytes.len()); // Truncate the bytes to the same point: wasm_bytes.truncate(253952); std::fs::write("/tmp/bad-extension.wasm", wasm_bytes.clone()).unwrap(); let manifest = Arc::new(ExtensionManifest { id: "the-extension".into(), name: "The Extension".into(), version: "0.0.1".into(), schema_version: SchemaVersion(1), description: Default::default(), repository: Default::default(), authors: Default::default(), lib: LibManifestEntry { kind: None, version: None, }, themes: Default::default(), languages: Default::default(), grammars: Default::default(), language_servers: Default::default(), }); // 💥 let result = wasm_host .load_extension(wasm_bytes, manifest, cx.executor()) .await; dbg!(result.map(|_| ())); ``` Release Notes: - Fixed a crash that could occur when loading malformed Wasm extensions ([#10352](#10352)). --------- Co-authored-by: Max <max@zed.dev>
This PR fixes a potential panic that could occur when loading malformed Wasm files. We now use the `parse_wasm_extension_version` function that was previously used just to extract the Zed extension API version from the Wasm bytes as a pre-validation step. By parsing the entirety of the Wasm file here instead of returning as soon as we find the version, the invalid Wasm bytes are now surfaced as an `Err` instead of a panic. We were able to replicate the panic using the following test: ```rs #[gpui::test] async fn test_bad_wasm(cx: &mut TestAppContext) { init_test(cx); let wasm_host = cx.update(|cx| { WasmHost::new( FakeFs::new(cx.background_executor().clone()), FakeHttpClient::with_200_response(), FakeNodeRuntime::new(), Arc::new(LanguageRegistry::test(cx.background_executor().clone())), PathBuf::from("/the/work/dir".to_string()), cx, ) }); let mut wasm_bytes = std::fs::read("/Users/maxdeviant/Library/Application Support/Zed/extensions/installed/dart/extension.wasm").unwrap(); // This is the error message we were seeing in the stack trace: // range end index 267037 out of range for slice of length 253952 dbg!(&wasm_bytes.len()); // Truncate the bytes to the same point: wasm_bytes.truncate(253952); std::fs::write("/tmp/bad-extension.wasm", wasm_bytes.clone()).unwrap(); let manifest = Arc::new(ExtensionManifest { id: "the-extension".into(), name: "The Extension".into(), version: "0.0.1".into(), schema_version: SchemaVersion(1), description: Default::default(), repository: Default::default(), authors: Default::default(), lib: LibManifestEntry { kind: None, version: None, }, themes: Default::default(), languages: Default::default(), grammars: Default::default(), language_servers: Default::default(), }); // 💥 let result = wasm_host .load_extension(wasm_bytes, manifest, cx.executor()) .await; dbg!(result.map(|_| ())); ``` Release Notes: - Fixed a crash that could occur when loading malformed Wasm extensions ([#10352](#10352)). --------- Co-authored-by: Max <max@zed.dev>
) Cherry-picked Fix panic when loading malformed Wasm files (#10370) This PR fixes a potential panic that could occur when loading malformed Wasm files. We now use the `parse_wasm_extension_version` function that was previously used just to extract the Zed extension API version from the Wasm bytes as a pre-validation step. By parsing the entirety of the Wasm file here instead of returning as soon as we find the version, the invalid Wasm bytes are now surfaced as an `Err` instead of a panic. We were able to replicate the panic using the following test: ```rs #[gpui::test] async fn test_bad_wasm(cx: &mut TestAppContext) { init_test(cx); let wasm_host = cx.update(|cx| { WasmHost::new( FakeFs::new(cx.background_executor().clone()), FakeHttpClient::with_200_response(), FakeNodeRuntime::new(), Arc::new(LanguageRegistry::test(cx.background_executor().clone())), PathBuf::from("/the/work/dir".to_string()), cx, ) }); let mut wasm_bytes = std::fs::read("/Users/maxdeviant/Library/Application Support/Zed/extensions/installed/dart/extension.wasm").unwrap(); // This is the error message we were seeing in the stack trace: // range end index 267037 out of range for slice of length 253952 dbg!(&wasm_bytes.len()); // Truncate the bytes to the same point: wasm_bytes.truncate(253952); std::fs::write("/tmp/bad-extension.wasm", wasm_bytes.clone()).unwrap(); let manifest = Arc::new(ExtensionManifest { id: "the-extension".into(), name: "The Extension".into(), version: "0.0.1".into(), schema_version: SchemaVersion(1), description: Default::default(), repository: Default::default(), authors: Default::default(), lib: LibManifestEntry { kind: None, version: None, }, themes: Default::default(), languages: Default::default(), grammars: Default::default(), language_servers: Default::default(), }); // 💥 let result = wasm_host .load_extension(wasm_bytes, manifest, cx.executor()) .await; dbg!(result.map(|_| ())); ``` Release Notes: - Fixed a crash that could occur when loading malformed Wasm extensions ([#10352](#10352)). --------- Co-authored-by: Max <max@zed.dev> Co-authored-by: Marshall Bowers <elliott.codes@gmail.com> Co-authored-by: Max <max@zed.dev>
Can confirm, it works. |
) Cherry-picked Fix panic when loading malformed Wasm files (#10370) This PR fixes a potential panic that could occur when loading malformed Wasm files. We now use the `parse_wasm_extension_version` function that was previously used just to extract the Zed extension API version from the Wasm bytes as a pre-validation step. By parsing the entirety of the Wasm file here instead of returning as soon as we find the version, the invalid Wasm bytes are now surfaced as an `Err` instead of a panic. We were able to replicate the panic using the following test: ```rs #[gpui::test] async fn test_bad_wasm(cx: &mut TestAppContext) { init_test(cx); let wasm_host = cx.update(|cx| { WasmHost::new( FakeFs::new(cx.background_executor().clone()), FakeHttpClient::with_200_response(), FakeNodeRuntime::new(), Arc::new(LanguageRegistry::test(cx.background_executor().clone())), PathBuf::from("/the/work/dir".to_string()), cx, ) }); let mut wasm_bytes = std::fs::read("/Users/maxdeviant/Library/Application Support/Zed/extensions/installed/dart/extension.wasm").unwrap(); // This is the error message we were seeing in the stack trace: // range end index 267037 out of range for slice of length 253952 dbg!(&wasm_bytes.len()); // Truncate the bytes to the same point: wasm_bytes.truncate(253952); std::fs::write("/tmp/bad-extension.wasm", wasm_bytes.clone()).unwrap(); let manifest = Arc::new(ExtensionManifest { id: "the-extension".into(), name: "The Extension".into(), version: "0.0.1".into(), schema_version: SchemaVersion(1), description: Default::default(), repository: Default::default(), authors: Default::default(), lib: LibManifestEntry { kind: None, version: None, }, themes: Default::default(), languages: Default::default(), grammars: Default::default(), language_servers: Default::default(), }); // 💥 let result = wasm_host .load_extension(wasm_bytes, manifest, cx.executor()) .await; dbg!(result.map(|_| ())); ``` Release Notes: - Fixed a crash that could occur when loading malformed Wasm extensions ([#10352](#10352)). --------- Co-authored-by: Max <max@zed.dev> Co-authored-by: Marshall Bowers <elliott.codes@gmail.com> Co-authored-by: Max <max@zed.dev>
The fix for this just went out in v0.130.5. |
Sorry about not following up sooner (I'm UTC+12). Excellent work y'all, thank you. |
Check for existing issues
Describe the bug / provide steps to reproduce it
Install dart extension as suggested by Zed on opening a dart file.
Environment
Zed: v1.0.0 (Zed Dev 4151ba1)
OS: Linux 1.0.0
Memory: 31 GiB
Architecture: x86_64
If applicable, attach your
~/Library/Logs/Zed/Zed.log
file to this issue.The text was updated successfully, but these errors were encountered: