Skip to content

Program produces <<loop>> with GHC 9.0/9.2, but not with GHC 8.10

While attempting to upgrade the saw-script project, I have noticed that it will produce a runtime <<loop>> on GHC 9.0 and 9.2 on a program that did not used to <<loop>> with GHC 8.10. I believe this to be a regression, so I am reporting it here. Unfortunately, I have not been able to minimize the issue, but you can perform the following steps:

  1. Ensure you have Clang installed. In case it is important, I am using Clang 10.0.0 on 64-bit Ubuntu 20.04:

    $ clang --version
    clang version 10.0.0-4ubuntu1 
    Target: x86_64-pc-linux-gnu
    Thread model: posix
    InstalledDir: /usr/bin
  2. Clone https://github.com/GaloisInc/saw-script, enter the saw-script directory, and check out the ghc-9.0-9.2-bug branch:

    $ git clone https://github.com/GaloisInc/saw-script
    $ cd saw-script
    $ git checkout ghc-9.0-9.2-bug
  3. Put the following files in the saw-script directory:

    // column.c
    typedef enum {
        ColumnA = 0,
        ColumnB,
    } Column;
    
    int is_column_a(Column c) {
      return c == ColumnA;
    }
    // column.saw
    // bug.saw
    enable_experimental;
    
    env <- heapster_init_env "column" "column.bc";
    
    heapster_define_perm env "int32" " " "llvmptr 32" "exists x:bv 32.eq(llvmword(x))";
    
    heapster_define_perm env "Column" ""
        "llvmptr 32"
        "eq(llvmword(0)) or eq(llvmword(1))";
    
    heapster_typecheck_fun env "is_column_a"
        "().arg0:Column<> -o ret:int32<>";
  4. Compile column.c with Clang like so:

    $ clang-10 -emit-llvm -c column.c -o column.bc
  5. Run the following command to run saw using GHC 8.10.7, which should succeed:

    $ cabal run exe:saw -w ghc-8.10.7 -- bug.saw
    Resolving dependencies...
    Up to date
    
    
    
    [00:19:37.163] Loading file "/home/ryanglscott/Documents/Hacking/Haskell/saw-script/bug.saw"
  6. Now run the same command with GHC 9.0.2 or 9.2.4. These will loop:

    $ cabal run exe:saw -w ghc-9.0.2 -- bug.saw    
    Resolving dependencies...
    Up to date
    
    
    
    [00:21:46.189] Loading file "/home/ryanglscott/Documents/Hacking/Haskell/saw-script/bug.saw"
    [00:21:46.531] <<loop>>
    $ cabal run exe:saw -w ghc-9.2.4 -- bug.saw
    Resolving dependencies...
    Up to date
    
    
    
    [00:22:49.344] Loading file "/home/ryanglscott/Documents/Hacking/Haskell/saw-script/bug.saw"
    [00:22:49.682] <<loop>>

    Note that you should only use GHC 9.2.4 or earlier, not 9.2.5, as GHC 9.2.5 will trigger #22491 (closed).

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information