Skip to content

Segmentation fault when run or build large Yesod App

Summary

  • When run a large Yesod App (large means have 2000+ routes), I got segmentation fault first time hit any home route.
  • When build a Yesod App (with 5000+ routes), I'm unable to build with errors like following
/var/folders/r9/zj36xjlx377ggww2mz650s3h0000gn/T/ghc110_0/ghc_47.s:780961:2: error:
     error: fixup value out of range
            cbnz x17, LclVXJ
            ^
       |
780961 |         cbnz x17, LclVXJ
       |  ^

/var/folders/r9/zj36xjlx377ggww2mz650s3h0000gn/T/ghc110_0/ghc_47.s:781041:2: error:
     error: fixup value out of range
            cbnz x17, LclVWx
            ^
       |
781041 |         cbnz x17, LclVWx
       |  ^

/var/folders/r9/zj36xjlx377ggww2mz650s3h0000gn/T/ghc110_0/ghc_47.s:781121:2: error:
     error: fixup value out of range
            cbnz x17, LclVVl
            ^
       |
781121 |         cbnz x17, LclVVl
       |  ^

<no location info>: error:
    `gcc' failed in phase `Assembler'. (Exit code: 1)
Error: cabal: Failed to build yesodweb-sample-0.0.0 (which is required by
exe:yesodweb-sample from yesodweb-sample-0.0.0).

Steps to reproduce

Segmentation error

  1. Install ghc-9.6.3 and cabal-3.10 via ghcup

  2. Check out this sample project

  3. Run cabal clean && cabal run

  4. Open browser at http://localhost:3000

  5. The terminal where runs cabal run will show something like this

    127.0.0.1 - - [06/Nov/2023:10:00:01 -0800] "GET / HTTP/1.1" 200 581 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/119.0"
    [1]    92475 segmentation fault  cabal run

Build failure

  1. Install GHC and cabal (same as last one)
  2. Checkout the project and switch to branch poc-5k-routes
  3. Run cabal clean && cabal build
  4. You'll see the compilation 'gcc' failed in phase 'Assembler' (it takes a while)

Expected behavior

The Web App shall be able to run properly and handle all routes.

Environment

  • GHC version used: 9.6.3

Optional:

  • Operating System: MacOS 14.1
  • System Architecture: Apple M1
Edited by Haisheng, Wu
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information