Repository navigation
Closed
Labels
status:needs-triageAn issue that hasn't had any proper look
Milestone
Description
Describe the bug
I'm seeing Nushell hang occasionally in macOS as I'm developing. I managed to catch it and attach a debugger to see where it was:
* frame #0: 0x0000000190a4cacc libsystem_kernel.dylib`read + 8
frame #1: 0x0000000102423170 nu`crossterm::event::sys::unix::file_descriptor::FileDesc::read::hfbd23575769f9401 + 28
frame #2: 0x00000001024216b4 nu`_$LT$crossterm..event..source..unix..mio..UnixInternalEventSource$u20$as$u20$crossterm..event..source..EventSource$GT$::try_read::hbbc0fab5c8f663e4 + 320
frame #3: 0x00000001024226f8 nu`crossterm::event::read::InternalEventReader::poll::h36c3e8abbd07d8a9 + 360
frame #4: 0x000000010241ea0c nu`crossterm::event::poll_internal::h0048b8dda3aba103 + 172
frame #5: 0x000000010242307c nu`crossterm::cursor::sys::unix::read_position_raw::hd8205425dcf4d786 + 140
frame #6: 0x0000000102d99548 nu`reedline::painting::painter::Painter::initialize_prompt_position::h536603ca530d65c6 + 84
frame #7: 0x0000000102d8a024 nu`reedline::engine::Reedline::read_line::hf3ee01bf075925f5 + 80
frame #8: 0x00000001024f09f8 nu`nu_cli::repl::evaluate_repl::h0038740f8bd590bd + 9328
frame #9: 0x00000001024ad2d0 nu`nu::run::run_repl::h9453fd09d0b40fa3 + 384
How to reproduce
- Start in zsh as root shell
- Run a release version of nushell
- From inside nushell, run
cargo runin the nushell repo - Immediately,
exit
Expected behavior
There shouldn't be any hang on exit.
Screenshots
No response
Configuration
| key | value |
|---|---|
| version | 0.83.1 |
| branch | main |
| commit_hash | 8403fff |
| build_os | macos-aarch64 |
| build_target | aarch64-apple-darwin |
| rust_version | rustc 1.69.0 (84c898d65 2023-04-16) |
| rust_channel | 1.69.0-aarch64-apple-darwin |
| cargo_version | cargo 1.69.0 (6e9a83356 2023-04-12) |
| build_time | 2023-07-29 05:50:17 +12:00 |
| build_rust_channel | debug |
| allocator | standard |
| features | default, sqlite, trash, which, zip |
| installed_plugins |
Additional context
No response
Metadata
Metadata
Assignees
Labels
status:needs-triageAn issue that hasn't had any proper look
Activity
WindSoilder commentedon Jul 30, 2023
I get the same issue on MacOS as well after I
exitnushellsophiajt commentedon Jul 30, 2023
@WindSoilder - is then when you do
cargo runor when you install nushell and runnu?WindSoilder commentedon Jul 31, 2023
when I do
cargo run. I can't reproduce it on releasednubinary.I suddendly found that I can reproduce it in debug mode everytime.
sophiajt commentedon Aug 1, 2023
bisect found it was caused by #9693
sophiajt commentedon Aug 1, 2023
Repro:
cargo runin the nushell repoexitfdncred commentedon Aug 1, 2023
I repro'd it too with your steps on MacOS.
[-]Nushell occasionally hangs (in debug mode?)[/-][+]Nushell hangs CPU in debug mode[/+]Revert 9693 to prevent CPU hangs (#9893)
IanManske commentedon Aug 2, 2023
Sorry about that! Does this happen in WSL as well? I am unable to reproduce this on Linux.
To make sure I'm running the repro steps properly:
Steps
zshas the initial shell (also tried with root permissions)cargo run -r -- -nor system nu v0.83.0:nu -ncargo run -- -n55565 kitty (kitty zsh)
exit(no hang?)exitzshMy suspicion is that in
foreground.rswe are not reaching line178for some reason. (This puts nushell back in control of the terminal.) Unfortunately I do not have a device running macOS to test, but I've made a branch with some debug prints if anyone is able to provide output.On my machine I get the following:
fdncred commentedon Aug 2, 2023
I'll try to repro in WSL.
fdncred commentedon Aug 2, 2023
I cannot repro it in WSL. I tried a few different ways unsuccessfully. I tried with
kgx,wezterm, andWindows Terminal. Now it makes me wonder if the problem is more macos-centric.I'm trying
cargo test --workspacenow in WSL, which is what @sholderbach had problems with, iirc.UPDATE: No issues with
cargo test --workspacein WSL. All this testing was on 778a00eIanManske commentedon Aug 2, 2023
Thanks for all the testing!
Yeah, there may be macOS specific behavior that I'm unaware of that's causing this. I'd have to do more research, but in the meantime, if someone could see if the debug prints that I mentioned before match on macOS, that would be much appreciated! Specifically, I am interested to see if the
tcsetpgrpon line178is being run, and, if not, whichifstatement is preventing it from being run.fdncred commentedon Aug 2, 2023
Hey @IanManske, I tried your branch. This is what I get with
cargo r.fdncred commentedon Aug 2, 2023
And here it is with
cargo run -- -nfdncred commentedon Aug 2, 2023
oops, both those tests were on MacOS. Maybe you wanted them ran on WSL since that whole block is disabled on macos with
#[cfg(all(target_family = "unix", not(target_os = "macos")))]IanManske commentedon Aug 2, 2023
Oh, I did not see that! Thanks for pointing that out.
Then that is the problem. If we are not supporting job control on MacOs (for now?) then
acquire_terminalinterminal.rsneeds to match and have the samecfgguard (or something like this).fdncred commentedon Aug 2, 2023
Why wouldn't we support it in MacOS? I figured it would work similarly as Linux.
IanManske commentedon Aug 2, 2023
I don't know, I would have assumed so as well. The relevant comment says
// Note: we exclude macos because the techniques below seem to have issues in macos 13 currently.which is a little vague.I guess I'll have to setup a macOS virtual machine to do some testing. I'll open an issue or PR with the findings/fixes once I'm done.
fdncred commentedon Aug 3, 2023
ok, sounds good. thanks for your help! we appreciate it.
Revert 9693 to prevent CPU hangs (nushell#9893)
Enable macOS foreground process handling (#9909)