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

Segmentation fault cargo run #25366

Closed
Angelk90 opened this issue Feb 21, 2025 · 12 comments · Fixed by #25393
Closed

Segmentation fault cargo run #25366

Angelk90 opened this issue Feb 21, 2025 · 12 comments · Fixed by #25393
Labels
panic / crash [core label]

Comments

@Angelk90
Copy link
Contributor

Summary

Steps to trigger the problem:

  1. Cargo Run
  2. Zed Crash

Or

  1. cargo run
  2. Open file
  3. Try to edit a file
  4. Zed Crash

All this happens when I try to build the latest version of zed.

Safari browser opens to Sign in to GitHub to continue to Zed Industries page every time i do cargo run and then zed crashes.

Last commit: aba89ba12a09d42bbfcb722b102ededd1d6aa608

Error:

2025-02-21 23:16:16.607 zed[55739:945921] +[IMKClient subclass]: chose IMKClient_Modern
2025-02-21 23:16:16.607 zed[55739:945921] +[IMKInputSession subclass]: chose IMKInputSession_Modern
[2025-02-21T23:18:57+01:00 ERROR zed] didn't receive login redirect
[1]    55739 segmentation fault  cargo run

Zed Version and System Specs

Zed: v0.175.3 (Zed Preview) 
OS: macOS 15.3.0
Memory: 16 GiB
Architecture: x86_64

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

Zed.log

@Angelk90
Copy link
Contributor Author

Another type of error I get:

Finished `dev` profile [unoptimized + debuginfo] target(s) in 5.18s
     Running `target/debug/zed`
2025-02-21 23:25:12.169 zed[57259:955514] +[IMKClient subclass]: chose IMKClient_Modern
2025-02-21 23:25:12.169 zed[57259:955514] +[IMKInputSession subclass]: chose IMKInputSession_Modern
Thread "main" panicked with "panic in a function that cannot unwind" at library/core/src/panicking.rs:221:5
https://github.com/zed-industries/zed/blob/aba89ba12a09d42bbfcb722b102ededd1d6aa608/src/library/core/src/panicking.rs#L221 (may not be uploaded, line may be incorrect if files modified)
   0: backtrace::backtrace::libunwind::trace
             at /Users/NAMEUSER/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.74/src/backtrace/libunwind.rs:116:5
      backtrace::backtrace::trace_unsynchronized
             at /Users/NAMEUSER/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.74/src/backtrace/mod.rs:66:5
   1: backtrace::backtrace::trace
             at /Users/NAMEUSER/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.74/src/backtrace/mod.rs:53:14
   2: backtrace::capture::Backtrace::create
             at /Users/NAMEUSER/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.74/src/capture.rs:292:9
   3: backtrace::capture::Backtrace::new
             at /Users/NAMEUSER/.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/NAMEUSER/Desktop/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_nounwind_fmt::runtime
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:112:18
      core::panicking::panic_nounwind_fmt
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:122:5
  10: core::panicking::panic_nounwind
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:221:5
  11: core::panicking::panic_cannot_unwind
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:309:5
  12: gpui::platform::mac::window::step
             at /Users/NAMEUSER/Desktop/zed/crates/gpui/src/platform/mac/window.rs:1650:1
  13: <unknown>
  14: <unknown>
  15: <unknown>
  16: <unknown>
  17: <unknown>
  18: <unknown>
  19: <unknown>
  20: <unknown>
  21: <unknown>
  22: <unknown>
  23: <unknown>
  24: <unknown>
  25: <unknown>
  26: <unknown>
  27: <() as objc::message::MessageArguments>::invoke
             at /Users/NAMEUSER/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/mod.rs:128:17
  28: objc::message::platform::send_unverified
             at /Users/NAMEUSER/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc-0.2.7/src/message/apple/mod.rs:27:9
  29: objc::message::send_message
             at /Users/NAMEUSER/.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/NAMEUSER/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cocoa-0.26.0/src/appkit.rs:628:9
  30: <gpui::platform::mac::platform::MacPlatform as gpui::platform::Platform>::run
             at /Users/NAMEUSER/Desktop/zed/crates/gpui/src/platform/mac/platform.rs:453:13
  31: gpui::app::Application::run
             at /Users/NAMEUSER/Desktop/zed/crates/gpui/src/app.rs:164:9
  32: zed::main
             at /Users/NAMEUSER/Desktop/zed/crates/zed/src/main.rs:285:5
  33: core::ops::function::FnOnce::call_once
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ops/function.rs:250:5
  34: std::sys::backtrace::__rust_begin_short_backtrace
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/sys/backtrace.rs:152:18
  35: std::rt::lang_start::{{closure}}
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/rt.rs:162:18
  36: 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
  37: std::rt::lang_start
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/rt.rs:161:17
  38: _main
  39: <unknown>

@beniaminzagan
Copy link
Member

@maxdeviant i know you did some changes there recently, maybe a side effect of that?

@beniaminzagan beniaminzagan added the panic / crash [core label] label Feb 21, 2025
@Angelk90
Copy link
Contributor Author

Angelk90 commented Feb 21, 2025

Every time I do:
Cargo run, this part of code is executed:

pub async fn authenticate_and_connect(
self: &Arc<Self>,
try_provider: bool,
cx: &AsyncApp,
) -> anyhow::Result<()> {

fn authenticate(self: &Arc<Self>, cx: &AsyncApp) -> Task<Result<Credentials>> {
#[cfg(any(test, feature = "test-support"))]
if let Some(callback) = self.authenticate.read().as_ref() {
return callback(cx);
}
self.authenticate_with_browser(cx)
}

let mut url = http.build_url(&format!(
"/native_app_signin?native_app_port={}&native_app_public_key={}",
port, public_key_string
));

@Angelk90
Copy link
Contributor Author

@maxdeviant : I tried to print this part of code that calls the others:

async fn authenticate(client: Arc<Client>, cx: &AsyncApp) -> Result<()> {
    eprintln!(
        "authenticate {}, {}",
        stdout_is_a_pty(),
        client::IMPERSONATE_LOGIN.is_some()
    );
    
    if stdout_is_a_pty() {
        if client::IMPERSONATE_LOGIN.is_some() {
            client.authenticate_and_connect(false, cx).await?;
        } else {
            client.authenticate_and_connect(true, cx).await?
        }
    } else if client.has_credentials(cx).await {
        client.authenticate_and_connect(true, cx).await?;
    }
    Ok::<_, anyhow::Error>(())
}

Print:

authenticate true, false

Then this part is done:
client.authenticate_and_connect(true, cx).await?

Commits, that about this part:
a1223e0
21bb724

@maxdeviant
Copy link
Member

Safari browser opens to Sign in to GitHub to continue to Zed Industries page every time i do cargo run and then zed crashes.

What happens if you sign in?

@Angelk90
Copy link
Contributor Author

@maxdeviant : After logging in, if I run cargo run again.
It doesn't open my browser anymore, but if I open a file and try to edit it the app crashes.

I get errors like:
[1] 4918 segmentation fault cargo run

Or

Error like this identical one:

Thread "main" panicked with "panic in a function that cannot unwind" at library/core/src/panicking.rs:221:5
https://github.com/zed-industries/zed/blob/aba89ba12a09d42bbfcb722b102ededd1d6aa608/src/library/core/src/
panicking.rs#L221 (may not be uploaded, line may be incorrect if files modified)
   0: backtrace::backtrace::libunwind::trace

#25366 (comment)

@Angelk90
Copy link
Contributor Author

@maxdeviant :
I made a copy of the main branch.
I did some git reset --hard to understand in which commits the problems occur.

Zed starts crashing from this commit:
a8610fb

Pr:
#25040

In fact app crashes as soon as I write.

This is a problem I identified.

@tmickleydoyle : What version of macOS are you using?

@foxtran
Copy link

foxtran commented Feb 22, 2025

I have the same issue on MacOS

Code Type:             X86-64 (Native)
OS Version:            macOS 13.6.7 (22G720)
Report Version:        12

Error:

Crashed Thread:        0  main  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       UNKNOWN_0xD at 0x0000000000000000
Exception Codes:       0x000000000000000d, 0x0000000000000000

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11

Some part of stacktrace:

Thread 0 Crashed:: main Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib               	    0x7ff804adb217 objc_msgSend + 23
1   zed                           	       0x10a902735 _$LT$$LP$$RP$$u20$as$u20$objc..message..MessageArguments$GT$::invoke::h935ecc6e7e134aa1 + 53
2   zed                           	       0x10a901f8e objc::message::platform::send_unverified::hc1bb8e4667b8b532 + 110
3   zed                           	       0x10a505373 _$LT$gpui..platform..mac..platform..MacPlatform$u20$as$u20$gpui..platform..Platform$GT$::set_cursor_style::ha52be5529ee474a5 + 16691
4   zed                           	       0x10a45c7bf gpui::window::Window::reset_cursor_style::h3cee995cbbbe3088 + 159

@Angelk90
Copy link
Contributor Author

@maxdeviant : Instead error of opening the safari browser by itself, when you do cargo run and you have not previously done the login with github is due to this commit: a1223e0

Pr:
#25273

Possible problem this:

zed/crates/zed/src/main.rs

Lines 724 to 735 in f9a2fac

async fn authenticate(client: Arc<Client>, cx: &AsyncApp) -> Result<()> {
if stdout_is_a_pty() {
if client::IMPERSONATE_LOGIN.is_some() {
client.authenticate_and_connect(false, cx).await?;
} else {
client.authenticate_and_connect(true, cx).await?
}
} else if client.has_credentials(cx).await {
client.authenticate_and_connect(true, cx).await?;
}
Ok::<_, anyhow::Error>(())
}

Previously it was used:
if *credentials_provider::ZED_DEVELOPMENT_AUTH

@maxdeviant
Copy link
Member

@maxdeviant : Instead error of opening the safari browser by itself, when you do cargo run and you have not previously done the login with github is due to this commit: a1223e0

Pr: #25273

Possible problem this:

zed/crates/zed/src/main.rs

Lines 724 to 735 in f9a2fac

async fn authenticate(client: Arc, cx: &AsyncApp) -> Result<()> {
if stdout_is_a_pty() {
if client::IMPERSONATE_LOGIN.is_some() {
client.authenticate_and_connect(false, cx).await?;
} else {
client.authenticate_and_connect(true, cx).await?
}
} else if client.has_credentials(cx).await {
client.authenticate_and_connect(true, cx).await?;
}
Ok::<_, anyhow::Error>(())
}
Previously it was used: if *credentials_provider::ZED_DEVELOPMENT_AUTH

This is the expected behavior now that #25273 is merged.

From the information provided it sounds like this is unrelated to the segfault you are seeing.

@maxdeviant
Copy link
Member

@Angelk90 @foxtran Could you please try running locally with #25393 and see if that fixes the segmentation fault you are seeing?

@Angelk90
Copy link
Contributor Author

@maxdeviant : Yes, this fixes the crash issue.

maxdeviant added a commit that referenced this issue Feb 22, 2025
#25393)

This reverts commit a8610fb.

I've been seeing some reports of segmentation faults that appear to
point to this change as the culprit.

Closes #25366.

Release Notes:

- Community: Reverted #25040, so remove the corresponding entry from the
release notes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
panic / crash [core label]
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants