-
Notifications
You must be signed in to change notification settings - Fork 841
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 when running stack in zsh (MacOS) #5607
Comments
@paqg it looks like you're using an M1 Mac but I don't think |
I've experienced this too. M1 mac, haskell-stack installed via homebrew -- works fine on bash, segfaults on zsh. |
I'd like to note that I get the segmentation faults as well, but I do not get them when using zsh on iTerm2. I do get them using the default Terminal.app, Alacrity and WezTerm, though. Can anyone else confirm this is the case for them as well? I'm not sure what's different running zsh from a different terminal. |
stack build directly via cabal also have the same problem. |
I am having the same issue, running on an Apple Silicon Mac,
|
As a workaround I have created a small wrapper script that runs in Bash and passes its arguments along to #!/bin/bash
export PATH="/opt/homebrew/opt/llvm@12/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/llvm@12/lib"
export CPPFLAGS="-I/opt/homebrew/opt/llvm@12/include"
/opt/homebrew/bin/stack "$@" |
I would suggest changing the last line in @fwcd's script to
so quoted parameters work properly. |
Updated, thanks! |
I've encountered stack segfaulting on M1 too. It doesn't appear to be limited to when running under zsh. I've tried changing my shell to bash and when I log in via ssh and attempt to use mini:compiler kll$ echo $SHELL
/bin/bash
mini:compiler kll$ stack build
Segmentation fault: 11
mini:compiler kll$ Using stack in iTerm2 works just fine with zsh. Not sure how to debug further!? |
Having similar issue when running
Tried stack versions:
zsh
fish
bash
Update: if I sub-shell to fish again, it works too. I suppose this is an environment configuration issue
|
I can confirm that across around 10 M1 macs that I helped to configure for students, each with the same or similar configuration, the same error is present, and with the same symptoms - no crash in bash, no crash when piping output to /dev/null. In my own case, stack was working perfectly up until today, where the same segmentation fault started to occur with no changes to configuration on my part. Edit: with regards the comment below, I use iterm2 and vscode, and the error started popping up in both at the same time yesterday and has not gone away. |
I have the same issue when I use the Intellij IDE terminal. But on Iterm2 everything works fine. On the other hand on the Intellij terminal (/bin/zsh) It's like "The Bug of Schrodinger" because when I use the --verbose flag to find the origin of the problem, the issue disappears. And when I am not using the --verbose flag, I have the segmentation fault. But when I use a --verbose flag works fine surprisingly |
@larancibia so interesting! Adding the Edit: Using |
I am having the same issue while running stack setup leads to a segmentation fault, what can I do to fix this? |
The only way to make stack work stably on M1 macs is to use brew x86_64 under rosetta. In my case, the aarch64 version was unusable. Are there any ETAs for a fix? Is someone trying to investigate? |
In my case, I installed stack via ghcup. I found that wu@ThomasdeMacBook-Pro ~/Projects/Repositories % stack new myproj
[1] 40894 segmentation fault stack new myproj
139 wu@ThomasdeMacBook-Pro ~/Projects/Repositories % yash
Welcome to yash!
....
wu@ThomasdeMacBook-Pro Repositories 2$ stack new proj
The process was killed by SIGSEGV: Segmentation fault: 11
wu@ThomasdeMacBook-Pro ~/Projects/Repositories % echo $TERM_PROGRAM
Apple_Terminal |
For ghcup users, #!/usr/bin/env bash
export PATH="/opt/homebrew/opt/llvm@13/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/llvm@13/lib"
export CPPFLAGS="-I/opt/homebrew/opt/llvm@13/include"
$(ghcup whereis stack) "$@" |
I tried three terminals and
kitty 0.24.4zsh$ stack exec -- yesod devel
[1] 92940 segmentation fault stack exec -- yesod devel bash-3.2$ stack exec -- yesod devel
Segmentation fault: 11 However,
iTerm 2 Build 3.4.15 and macOS default Terminal 2.12 (443)Everything works as expected using both |
I noticed that creating a new package with an invalid name works as intended (an error is printed):
But creating one with a valid name segfaults:
It ain't much, but hopefully it'll give an investigator a better idea of what's going on 🤞 I'm happy to test and/or provide more information if that'd be helpful. PS. Tested in the same combinations as per my last comment, but now with macOS Monterey 12.3.1 and kitty 0.25.0. PPS. I tested my setup (same version of kitty, dotfiles etc.) on two x86 machines and they worked as intended (Fedora 35 and an Intel Mac). |
I ran into this issue as well, and adding the verbose flag helped. To add to what has been said:
|
Guess why... because stack doesn't install aarch64 binaries on your mac M1. Brew and ghcup do. M1 support in GHC is very new, so of course there may be some bugs. If anyone can pin this down, open a bug report for GHC. |
subscribing for notifications on future fix/workarounds. On M1 Mac mini macOS 11.6.1. I can run GHCi on zsh but not GHCUP which I installed using bash. I only switched to zsh today after months of prompts on Terminal.app to do so. Cabal doesn't work either. I guess this was some kinda $PATH issue, but seems to be a bigger issue. |
I have an M1 Mac as well and encountered this. I'm running the AArch64 based Stack in an AArch64 shell. Below are some commands I ran to verify the architectures, and shows that adding the After a single successful compilation with zsh$ # Current shell arch
zsh$ arch
arm64
zsh$ # Architecture of the stack executable
zsh$ file $(where stack)
/Users/kilo/.ghcup/bin/stack: Mach-O 64-bit executable arm64
zsh$ # For using --system-ghc, we get the architecture of the ghc in PATH
zsh$ file $(cat $(where ghc) | head -n 2 | tail -n 1 | awk -F'"' '{print $2}')/ghc
/Users/kilo/.ghcup/ghc/8.10.7/lib/ghc-8.10.7/bin/ghc: Mach-O 64-bit executable arm64
zsh$ # Try stack build
zsh$ stack build
zsh: segmentation fault stack build
zsh$ # Try stack build with system-ghc
zsh$ stack build --system-ghc
zsh: segmentation fault stack build
zsh$ stack build -v
Version 2.7.5, Git revision 717ec96c15520748f3fcee00f72504ddccaa30b5 (dirty) (163 commits) aarch64
Compiled with:
- Cabal-3.2.1.0
- Glob-0.10.1
- ....
# truncated but it all builds fine
zsh$ stack run --system-ghc -v
Version 2.7.5, Git revision 717ec96c15520748f3fcee00f72504ddccaa30b5 (dirty) (163 commits) aarch64
Compiled with:
- Cabal-3.2.1.0
- Glob-0.10.1
- ...
# Also truncated but it all builds fine |
Adding a slightly odd addendum here: on my machine it doesn't need to be $ stack ghci
zsh: segmentation fault stack ghci
$ $(stack ghci)
…
ghci> This suggests to me it's something about how edit: this |
I confirmed your finding on my mac also. If I run stack from a terminal, it works using bash or zsh. However, if I try running stack from ssh or through an emacs shell, it will segmentation fault 11 unless I call stack inside a subshell. |
Summary
When using stack in zsh it returns segfault.
Steps to reproduce
Using zsh to run:
But if you add the verbose flag, or redirect its stdout, it does not segfault.
run perfectly fine.
Note that not all commands fail, for example
work.
If one uses bash instead of zsh, it also runs without any problem.
Version
OS: MacOS 11.5.2 aarch64
Zsh: 5.8
Terminal: The MacOS builtin terminal
Installation method: homebrew
The text was updated successfully, but these errors were encountered: