第三次魅力 - 不确定性叠加/ GHC

时间:2018-01-20 22:45:40

标签: haskell ghc haskell-stack

我一直在尝试使用Stack在Ubuntu VM中安装软件包text。有趣的是 - 它第一次没有工作(Stack停止了段错误),它第二次没有工作(内部GHC错误),但它第三次工作。

使用以下Vagrantfile设置VM。

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|

  config.vm.box = "ubuntu/trusty64"
  config.ssh.forward_x11 = true

  config.vm.provider "virtualbox" do |vb|
    vb.memory = "1024"
    vb.cpus = 1
  end

  config.vm.hostname = "stack-project"
  config.vm.provision "shell", path: "root-bootstrap.sh"

root-bootstrap.sh文件是

#!/bin/bash
set -x
set -e

export DEBIAN_FRONTEND="noninteractive"

apt-get -qq update &>/dev/null
apt-get -qq install software-properties-common \
  pkg-config wget dpkg nano vim \
  &>/dev/null

# Haskell Stack
wget -qO- https://get.haskellstack.org/ | sh

chown -R vagrant $HOME

运行vagrant up && vagrant ssh后(需要将两个文件放在同一个文件夹中),我检查了堆栈是否已安装。

vagrant@stack-project:~$ stack --version
Version 1.6.3, Git revision b27e629b8c4ce369e3b8273f04db193b060000db (5454 commits) x86_64 hpack-0.20.0

我尝试安装text下一步

vagrant@stack-project:~$ stack install --resolver lts-10.3 text
Writing implicit global project config file to: /home/vagrant/.stack/global-project/stack.yaml
Note: You can change the snapshot via the resolver field there.
Using resolver: lts-10.3 specified on command line
Downloaded lts-10.3 build plan.
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.

Warning: Retry number 0 after a total delay of 0 us
         If you see this warning and stack fails to download, but running the
         command again solves the problem, please report here:
         https://github.com/commercialhaskell/stack/issues/3510
Downloaded ghc-8.2.2.
Installed GHC.
Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/
Downloading root
Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/
Downloading timestamp
Downloading snapshot
Downloading mirrors
Cannot update index (no local copy)
Downloading index
Updated package index downloaded
Update complete
Populated index cache.
Segmentation fault (core dumped)

我注意到,当发生segfault时,VM有大约75 MB的内存空闲。第二次运行时,

vagrant@stack-project:~$ stack install --resolver lts-10.3 text
[1 of 2] Compiling Main             ( /home/vagrant/.stack/setup-exe-src/setup-mPHDZzAJ.hs, /home/vagrant/.stack/setup-exe-src/setup-mPHDZzAJ.o )
[2 of 2] Compiling StackSetupShim   ( /home/vagrant/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /home/vagrant/.stack/setup-exe-src/setup-shim-mPHDZzAJ.o )
Linking /home/vagrant/.stack/setup-exe-cache/x86_64-linux/tmp-Cabal-simple_mPHDZzAJ_2.0.1.0_ghc-8.2.2 ...
text-1.2.2.2: download
text-1.2.2.2: configure
text-1.2.2.2: build

--  While building custom Setup.hs for package text-1.2.2.2 using:
      /home/vagrant/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_2.0.1.0_ghc-8.2.2 --builddir=.stack-work/dist/x86_64-linux/Cabal-2.0.1.0 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure (-6)
    Logs have been written to: /home/vagrant/.stack/global-project/.stack-work/logs/text-1.2.2.2.log

    Configuring text-1.2.2.2...
    Preprocessing library for text-1.2.2.2..
    Building library for text-1.2.2.2..
    [ 1 of 44] Compiling Data.Text.Encoding.Error ( Data/Text/Encoding/Error.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Encoding/Error.o )
    [ 2 of 44] Compiling Data.Text.Internal.Builder.Int.Digits ( Data/Text/Internal/Builder/Int/Digits.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Builder/Int/Digits.o )
    [ 3 of 44] Compiling Data.Text.Internal.Builder.RealFloat.Functions ( Data/Text/Internal/Builder/RealFloat/Functions.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Builder/RealFloat/Functions.o )
    [ 4 of 44] Compiling Data.Text.Internal.Encoding.Utf16 ( Data/Text/Internal/Encoding/Utf16.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Encoding/Utf16.o )
    [ 5 of 44] Compiling Data.Text.Internal.Encoding.Utf32 ( Data/Text/Internal/Encoding/Utf32.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Encoding/Utf32.o )
    [ 6 of 44] Compiling Data.Text.Internal.Functions ( Data/Text/Internal/Functions.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Functions.o )
    [ 7 of 44] Compiling Data.Text.Internal.Read ( Data/Text/Internal/Read.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Read.o )
    [ 8 of 44] Compiling Data.Text.Internal.Unsafe ( Data/Text/Internal/Unsafe.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Unsafe.o )
    [ 9 of 44] Compiling Data.Text.Internal.Unsafe.Shift ( Data/Text/Internal/Unsafe/Shift.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Unsafe/Shift.o )
    [10 of 44] Compiling Data.Text.Array  ( Data/Text/Array.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Array.o )
    [11 of 44] Compiling Data.Text.Internal.Unsafe.Char ( Data/Text/Internal/Unsafe/Char.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Unsafe/Char.o )
    [12 of 44] Compiling Data.Text.Internal.Encoding.Utf8 ( Data/Text/Internal/Encoding/Utf8.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Encoding/Utf8.o )
    [13 of 44] Compiling Data.Text.Internal ( Data/Text/Internal.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal.o )
    [14 of 44] Compiling Data.Text.Internal.Search ( Data/Text/Internal/Search.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Search.o )
    [15 of 44] Compiling Data.Text.Internal.Fusion.Size ( Data/Text/Internal/Fusion/Size.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Fusion/Size.o )
    [16 of 44] Compiling Data.Text.Internal.Fusion.Types ( Data/Text/Internal/Fusion/Types.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Fusion/Types.o )
    [17 of 44] Compiling Data.Text.Internal.Fusion.CaseMapping ( Data/Text/Internal/Fusion/CaseMapping.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Fusion/CaseMapping.o )
    [18 of 44] Compiling Data.Text.Internal.Fusion.Common ( Data/Text/Internal/Fusion/Common.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Fusion/Common.o )
    [19 of 44] Compiling Data.Text.Unsafe ( Data/Text/Unsafe.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Unsafe.o )
    [20 of 44] Compiling Data.Text.Internal.Private ( Data/Text/Internal/Private.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Private.o )
    [21 of 44] Compiling Data.Text.Internal.Fusion ( Data/Text/Internal/Fusion.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Fusion.o )
    [22 of 44] Compiling Data.Text.Show   ( Data/Text/Show.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Show.o )
    [23 of 44] Compiling Data.Text.Internal.Encoding.Fusion.Common ( Data/Text/Internal/Encoding/Fusion/Common.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Encoding/Fusion/Common.o )
    [24 of 44] Compiling Data.Text.Internal.Lazy.Encoding.Fusion ( Data/Text/Internal/Lazy/Encoding/Fusion.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Lazy/Encoding/Fusion.o )
    [25 of 44] Compiling Data.Text.Internal.Encoding.Fusion ( Data/Text/Internal/Encoding/Fusion.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Internal/Encoding/Fusion.o )
    [26 of 44] Compiling Data.Text.Encoding ( Data/Text/Encoding.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Encoding.o )
    [27 of 44] Compiling Data.Text.Foreign ( Data/Text/Foreign.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text/Foreign.o )
    [28 of 44] Compiling Data.Text        ( Data/Text.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build/Data/Text.o )
    ghc: internal error: Unable to commit 1048576 bytes of memory
        (GHC version 8.2.2 for x86_64_unknown_linux)
        Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

您认为重新运行stack install会再次出现相同的GHC错误,对吗?错。

vagrant@stack-project:~$ stack install --cabal-verbose --resolver lts-10.3 text
text-1.2.2.2: configure
text-1.2.2.2: build
text-1.2.2.2: copy/register

作为检查,我尝试使用stack ghci --ghc-options "-package text",它工作正常,我可以正常使用这些功能。我安装了megaparsec(任何库,具体取决于text都会这样做)并且安装得很好。

我遇到的堆栈错误,GHC错误和幽灵是什么组合?

其他可能相关的内容:

  1. Ticket 4012 - 编制结果不确定。如果我在猜测,这是第二次和第三次之间的差异。里程碑版本目前是8.4.1,而lts-10.3中的GHC是8.2.2。
  2. ICFP 2016 paper(间接?)声称GHC 8.0.2具有确定性。

0 个答案:

没有答案