Skip to content
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

Crash when an edit prediction suggests inserting a newline immediately after the final message header in the prompt editor #25377

Open
maxbrunsfeld opened this issue Feb 22, 2025 · 2 comments

Comments

@maxbrunsfeld
Copy link
Collaborator

maxbrunsfeld commented Feb 22, 2025

Summary

Steps to trigger the problem:

  1. Set up a prompt editor with the conversation below
  2. Type on the last line of the conversation until an edit prediction appears
  3. 💥 panic
convo
[You]

Don't begin responses with "Certainly!"



is a tomato a fruit or a vegetable?

[Assistant]

Botanically speaking, a tomato is a fruit since it develops from the flower of the plant and contains seeds. However, from a culinary perspective, tomatoes are typically treated as vegetables due to their savory flavor profile and how they're used in cooking.

This actually led to a famous U.S. Supreme Court case in 1893 (Nix v. Hedden) where the Court ruled that tomatoes should be classified as vegetables for tax purposes, even though they are botanically fruits. The ruling was based on how tomatoes were commonly used and understood in everyday life rather than their botanical classification.

[You]

tell me about the decision

[Assistant]

The Nix v. Hedden case (1893) arose because of tariff laws at the time. John Nix, a produce importer, sued Edward Hedden, a tax collector at the Port of New York, to recover taxes he had paid on imported tomatoes.

The Tariff Act of 1883 required a 10% tax on imported vegetables but not on fruits. Nix argued that tomatoes were technically fruits, so they shouldn't be taxed. His lawyers presented botanical evidence showing that tomatoes, like other fruits, grow from flowers and contain seeds.

However, Justice Horace Gray, writing for a unanimous Supreme Court, ruled against Nix. The Court's reasoning was pragmatic rather than scientific - they decided that tomatoes should be classified according to their common usage in everyday life. Since people used tomatoes like vegetables in cooking (served with dinner rather than dessert), they should be taxed as vegetables.

The Court noted that while botanists classified tomatoes as fruit, in "common language of the people," they were vegetables. This ruling set an interesting precedent about how common usage can sometimes take precedence over scientific classification in legal matters.

[You]

Zed Version and System Specs

Zed: v0.176.0 (Zed Nightly b9ca240)
OS: macOS 14.3.0
Memory: 128 GiB
Architecture: aarch64

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

Zed.log
Thread "main" panicked with "attempt to subtract with overflow" at crates/editor/src/display_map/block_map.rs:717:45
https://github.com/zed-industries/zed/blob/2e302b1a7c3c37e7c3c51cc9c521e613d3e7c2dc/src/crates/editor/src/display_map/block_map.rs#L717 (may not be uploaded, line may be incorrect if files modified)
   0: backtrace::backtrace::libunwind::trace
             at /Users/max/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.74/src/backtrace/libunwind.rs:116:5
      backtrace::backtrace::trace_unsynchronized
             at /Users/max/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.74/src/backtrace/mod.rs:66:5
   1: backtrace::backtrace::trace
             at /Users/max/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.74/src/backtrace/mod.rs:53:14
   2: backtrace::capture::Backtrace::create
             at /Users/max/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.74/src/capture.rs:292:9
   3: backtrace::capture::Backtrace::new
             at /Users/max/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.74/src/capture.rs:257:22
   4: zed::reliability::init_panic_hook::{{closure}}
             at /Users/max/code/zed/crates/zed/src/reliability.rs:56:29
   5: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/alloc/src/boxed.rs:2084:9
      std::panicking::rust_panic_with_hook
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:808:13
   6: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:667:13
   7: std::sys::backtrace::__rust_end_short_backtrace
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/sys/backtrace.rs:168:18
   8: rust_begin_unwind
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:665:5
   9: core::panicking::panic_fmt
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:74:14
  10: core::panicking::panic_const::panic_const_sub_overflow
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:181:21
  11: editor::display_map::block_map::BlockMap::sync
             at /Users/max/code/zed/crates/editor/src/display_map/block_map.rs:717:45
  12: editor::display_map::block_map::BlockMap::read
             at /Users/max/code/zed/crates/editor/src/display_map/block_map.rs:447:9
  13: editor::display_map::DisplayMap::snapshot
             at /Users/max/code/zed/crates/editor/src/display_map.rs:175:30
  14: editor::Editor::handle_input::{{closure}}::{{closure}}
             at /Users/max/code/zed/crates/editor/src/editor.rs:3053:61
  15: <gpui::app::App as gpui::AppContext>::update_entity::{{closure}}
             at /Users/max/code/zed/crates/gpui/src/app.rs:1644:26
  16: gpui::app::App::update
             at /Users/max/code/zed/crates/gpui/src/app.rs:422:22
  17: <gpui::app::App as gpui::AppContext>::update_entity
             at /Users/max/code/zed/crates/gpui/src/app.rs:1642:9
  18: <gpui::app::context::Context<T> as gpui::AppContext>::update_entity
             at /Users/max/code/zed/crates/gpui/src/app/context.rs:694:9
  19: gpui::app::entity_map::Entity<T>::update
             at /Users/max/code/zed/crates/gpui/src/app/entity_map.rs:441:9
  20: editor::Editor::handle_input::{{closure}}
             at /Users/max/code/zed/crates/editor/src/editor.rs:3053:23
  21: editor::Editor::transact
             at /Users/max/code/zed/crates/editor/src/editor.rs:12116:9
  22: editor::Editor::handle_input
             at /Users/max/code/zed/crates/editor/src/editor.rs:3031:9
  23: <editor::Editor as gpui::input::EntityInputHandler>::replace_text_in_range::{{closure}}
             at /Users/max/code/zed/crates/editor/src/editor.rs:16751:13
  24: editor::Editor::transact
             at /Users/max/code/zed/crates/editor/src/editor.rs:12116:9
  25: <editor::Editor as gpui::input::EntityInputHandler>::replace_text_in_range
             at /Users/max/code/zed/crates/editor/src/editor.rs:16713:9
  26: <gpui::input::ElementInputHandler<V> as gpui::platform::InputHandler>::replace_text_in_range::{{closure}}
             at /Users/max/code/zed/crates/gpui/src/input.rs:131:13
  27: <gpui::app::App as gpui::AppContext>::update_entity::{{closure}}
             at /Users/max/code/zed/crates/gpui/src/app.rs:1644:26
  28: gpui::app::App::update
             at /Users/max/code/zed/crates/gpui/src/app.rs:422:22
  29: <gpui::app::App as gpui::AppContext>::update_entity
             at /Users/max/code/zed/crates/gpui/src/app.rs:1642:9
  30: gpui::app::entity_map::Entity<T>::update
             at /Users/max/code/zed/crates/gpui/src/app/entity_map.rs:441:9
  31: <gpui::input::ElementInputHandler<V> as gpui::platform::InputHandler>::replace_text_in_range
             at /Users/max/code/zed/crates/gpui/src/input.rs:130:9
  32: gpui::platform::PlatformInputHandler::replace_text_in_range::{{closure}}
             at /Users/max/code/zed/crates/gpui/src/platform.rs:736:17
  33: gpui::app::async_context::AsyncWindowContext::update::{{closure}}
             at /Users/max/code/zed/crates/gpui/src/app/async_context.rs:258:57
  34: gpui::app::App::update_window_id::{{closure}}
             at /Users/max/code/zed/crates/gpui/src/app.rs:1008:26
  35: gpui::app::App::update
             at /Users/max/code/zed/crates/gpui/src/app.rs:422:22
  36: gpui::app::App::update_window_id
             at /Users/max/code/zed/crates/gpui/src/app.rs:997:9
  37: <gpui::app::App as gpui::AppContext>::update_window
             at /Users/max/code/zed/crates/gpui/src/app.rs:1669:9
  38: <gpui::app::async_context::AsyncApp as gpui::AppContext>::update_window
             at /Users/max/code/zed/crates/gpui/src/app/async_context.rs:92:9
  39: gpui::app::async_context::AsyncWindowContext::update
             at /Users/max/code/zed/crates/gpui/src/app/async_context.rs:257:9
  40: gpui::platform::PlatformInputHandler::replace_text_in_range
             at /Users/max/code/zed/crates/gpui/src/platform.rs:734:9
  41: gpui::platform::mac::window::insert_text::{{closure}}
             at /Users/max/code/zed/crates/gpui/src/platform/mac/window.rs:1743:13
  42: gpui::platform::mac::window::with_input_handler
             at /Users/max/code/zed/crates/gpui/src/platform/mac/window.rs:1982:22
  43: gpui::platform::mac::window::insert_text
             at /Users/max/code/zed/crates/gpui/src/platform/mac/window.rs:1742:9
  44: <unknown>
  45: <unknown>
  46: <unknown>
  47: <unknown>
  48: <unknown>
  49: <unknown>
  50: <unknown>
  51: <unknown>
  52: <unknown>
  53: <unknown>
  54: <unknown>
  55: <unknown>
  56: <unknown>
  57: <unknown>
  58: <unknown>
  59: <unknown>
  60: <unknown>
  61: <unknown>
  62: <unknown>
  63: <unknown>
  64: <unknown>
  65: <unknown>
  66: <unknown>
  67: <unknown>
  68: <unknown>
  69: <unknown>
  70: <unknown>
  71: <unknown>
  72: <unknown>
  73: <unknown>
  74: <unknown>
  75: <unknown>
  76: <(A,) as objc::message::MessageArguments>::invoke
             at /Users/max/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/mod.rs:128:17
  77: objc::message::platform::send_unverified
             at /Users/max/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/apple/mod.rs:27:9
  78: objc::message::send_message
             at /Users/max/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/mod.rs:178:5
      gpui::platform::mac::window::handle_key_event
             at /Users/max/code/zed/crates/gpui/src/platform/mac/window.rs:1338:9
  79: gpui::platform::mac::window::handle_key_down
             at /Users/max/code/zed/crates/gpui/src/platform/mac/window.rs:1209:5
  80: <unknown>
  81: <unknown>
  82: <unknown>
  83: <unknown>
  84: <unknown>
  85: <() as objc::message::MessageArguments>::invoke
             at /Users/max/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/mod.rs:128:17
  86: objc::message::platform::send_unverified
             at /Users/max/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/apple/mod.rs:27:9
  87: objc::message::send_message
             at /Users/max/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/mod.rs:178:5
      <*mut objc::runtime::Object as cocoa::appkit::NSApplication>::run
             at /Users/max/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cocoa-0.26.0/src/appkit.rs:628:9
  88: <gpui::platform::mac::platform::MacPlatform as gpui::platform::Platform>::run
             at /Users/max/code/zed/crates/gpui/src/platform/mac/platform.rs:453:13
  89: gpui::app::Application::run
             at /Users/max/code/zed/crates/gpui/src/app.rs:164:9
  90: zed::main
             at /Users/max/code/zed/crates/zed/src/main.rs:285:5
  91: core::ops::function::FnOnce::call_once
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ops/function.rs:250:5
  92: std::sys::backtrace::__rust_begin_short_backtrace
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/sys/backtrace.rs:152:18
  93: std::rt::lang_start::{{closure}}
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/rt.rs:162:18
  94: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ops/function.rs:284:13
      std::panicking::try::do_call
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:557:40
      std::panicking::try
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:521:19
      std::panic::catch_unwind
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panic.rs:350:14
      std::rt::lang_start_internal::{{closure}}
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/rt.rs:141:48
      std::panicking::try::do_call
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:557:40
      std::panicking::try
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:521:19
      std::panic::catch_unwind
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panic.rs:350:14
      std::rt::lang_start_internal
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/rt.rs:141:20
  95: std::rt::lang_start
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/rt.rs:161:17
  96: _main
@foxtran
Copy link

foxtran commented Feb 22, 2025

Looks like it is related to #25366

@maxdeviant
Copy link
Member

Looks like it is related to #25366

I don't believe these two panics are related.

@maxbrunsfeld maxbrunsfeld changed the title Crash when an edit prediction appears while editing the last line in a prompt editor Crash when an edit prediction suggests inserting a newline immediately after the final message header in the prompt editor Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants