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 in stack repl #6134

Closed
MaddyGuthridge opened this issue Jun 1, 2023 · 3 comments
Closed

Segmentation fault in stack repl #6134

MaddyGuthridge opened this issue Jun 1, 2023 · 3 comments

Comments

@MaddyGuthridge
Copy link

MaddyGuthridge commented Jun 1, 2023

Please follow the steps below for reporting a bug in Stack:

Make sure that you are using the latest release (currently Stack 2.11.1). See the
upgrade instructions
to upgrade.

Please use the following schema for your bug report:

General summary/comments

When I run certain commands in the Stack REPL, it causes a segmentation fault.

Steps to reproduce

For example:

  1. Run stack repl
  2. add_two = (+) 2
  3. add_two 3
  4. Observe that the correct output is printed, before a segfault occurs.

Expected

The output is printed correctly, then the REPL continues normally.

Actual

After the output is printed, a segmentation fault occurs, and the REPL exits with code 139

If you suspect that a Stack command misbehaved, please include the output of
that command in --verbose mode. If the output is larger than a page please
paste the output in a Gist.

I cannot reproduce the issue when the --verbose flag is given.

stack repl

Note: No local targets specified, so a plain ghci will be started with no package hiding or package options.
      
      You are using snapshot: lts-20.23
      
      If you want to use package hiding and options, then you can try one of the following:
      
      * If you want to start a different project configuration than /home/migue/.stack/global-project/stack.yaml, then you can use stack init to create a new stack.yaml for the packages in the current
        directory. 
        
      * If you want to use the project configuration at /home/migue/.stack/global-project/stack.yaml, then you can add to its 'packages' field.
      
Configuring GHCi with the following packages:
GHCi, version 9.2.7: https://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/migue/.cache/stack/ghci-script/2a3bbd58/ghci-script
ghci> add_two = (+) 2
ghci> add_two 3
5
ghc: mmap 4096 bytes at (nil): Cannot allocate memory
ghc: Try specifying an address with +RTS -xm<addr> -RTS
[1]    6917 segmentation fault (core dumped)  stack repl

Stack version

stack --version
Version 2.11.1, Git revision c1167a6abc3f4978ccded5ba0246a57387da0e2f x86_64 hpack-0.35.2

Method of installation

  • Official binary, downloaded via haskellstack.org or from Stack's repository

Platform

  • Fedora 38 Linux

Other observations

I use zsh as my shell, and the error does not occur if I run Stack from within bash. This could indicate similarity to #5607 (although I created a new issue due to it being specifically for MacOS).

Edit: I appear to get similar segfault errors under bash, just with different inputs.

@mpilgrem
Copy link
Member

mpilgrem commented Jun 1, 2023

@MiguelGuthridge, thanks for reporting. I can't reproduce this on Windows, so it may well be operating system-specific.

To collect some more information about your experience, when you start up stack repl, what is the initial output? Are you running stack repl outside of any project folder (that is, is stack repl getting its stack.yaml configuration from Stack's 'global project' in the Stack root)? If yes, what is in that stack.yaml configuration on your machine?

@MaddyGuthridge
Copy link
Author

The full output is listed above. I'm outside of a project folder - this is my second day learning Haskell, so I'm barely writing single files, let alone projects at this point.

I did notice that I was able to get similar crashes in GHCI, just with different output. In the mean time, my course admins seem to have done some further investigation, and it appears to be a kernel-related issue. Currently, my machine is on Kernel 6.2.15, and the fix is only present in Kernel 6.3.4, so I'll just have to wait a few weeks for it to be resolved :(

I'll also have to investigate to see if I can use GHC >= 9.4.x in my course, since it apparently also fixes the issues. Sadly until there is LSP support, I'll be unable to use 9.2.8 which appears to backport the fix.

Unless there's anything that can be fixed on the Stack end of things, feel free to close this :)

@mpilgrem
Copy link
Member

mpilgrem commented Jun 1, 2023

Given what your course admins have identified, this looks to be an upstream issue and I will close. There is no Stackage snapshot (yet) for GHC 9.2.8, but Stack should work if you specify in the relevant stack.yaml:

resolver: lts-20.23 # GHC 9.2.7
compiler: ghc-9.2.8 # Override snapshot with GHC 9.2.8

See https://docs.haskellstack.org/en/stable/yaml_configuration/#compiler.

@mpilgrem mpilgrem closed this as completed Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants