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

Closed
nh2 opened this Issue Sep 6, 2016 · 1 comment

Projects

None yet

3 participants

@nh2
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 $?
139

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).

@borsboom borsboom added this to the P1: Must milestone Sep 6, 2016
@snoyberg
Contributor

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

@borsboom borsboom closed this in cb26f44 Sep 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment