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

Docker: Aborting an initial stack exec can turn all futher stack execs into segfaults #2568

nh2 opened this issue Sep 6, 2016 · 1 comment


Copy link

nh2 commented Sep 6, 2016

When using stack with docker, I ran and then pressed Ctrl-C:

stack exec -- ls
Downloading Docker-compatible stack executable
Downloaded stack-1.1.2.                                    
^Cuser interrupt

Following this, all my stack exec commands failed with exit code 139:

$ stack exec -- ls
$ echo $?

Using stack exec --verbose, I determined the path of the used stack to be ~/.stack/programs/x86_64-linux/stack-1.1.2/stack; running that directly from the host showed that it would immediately segfault. ls showed that this stack binary was only 1.9 MB in size, which is way too small. My Ctrl-C had apparently aborted the step that made stack copy itself to ~/.stack/programs/x86_64-linux/stack-1.1.2/stack, and from then on stack did not recover from this. The solution was to remove ~/.stack/programs/x86_64-linux/stack-1.1.2/stack, which made stack copy it there anew.

This is on stack-1.2.2 on Ubuntu 16.04.

I think the fix for this would be to always check that files stack puts into place are still there with the right file size, which guards against premature copy aborts with Ctrl-C or computer crashes (and is much faster than hashing the file contents, which would add a recurring startup overhead).

Copy link

How about doing a cautious file write kind of thing, where you write the file to a temporary location in the same directory and then use renameFile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

3 participants