#14089 closed bug (invalid)

Segmentation fault/access violation using Yesod and Postgresql

Reported by: Burtannia Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.0.2
Keywords: Cc:
Operating System: Windows Architecture: x86_64 (amd64)
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by RyanGlScott)

When trying to build a Yesod site with Postgresql I got the following:

website-0.0.0: configure (lib)
Configuring website-0.0.0...
website-0.0.0: build (lib)
Preprocessing library website-0.0.0...
[ 1 of 11] Compiling Settings         ( src\Settings.hs, .stack-work\dist\ca59d0ab\build\Settings.o )
[ 2 of 11] Compiling Settings.StaticFiles ( src\Settings\StaticFiles.hs, .stack-work\dist\ca59d0ab\build\Settings\StaticFiles.o )
Segmentation fault/access violation in generated code

--  While building package website-0.0.0 using:
      C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_1.24.2.0_ghc-8.0.2.exe --builddir=.stack-work\dist\ca59d0ab build lib:website --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1

Change History (11)

comment:1 Changed 19 months ago by Burtannia

Description: modified (diff)

comment:2 Changed 19 months ago by Burtannia

Version: 8.2.18.0.2

comment:3 Changed 19 months ago by Phyx-

Hi,

Do you have a way for me to reproduce this? What's this website-0.0.0 ? Do you have a project I can use to trigger this? Just installing yesod doesn't seem to fail.

comment:4 Changed 19 months ago by RyanGlScott

Description: modified (diff)
Status: newinfoneeded

comment:5 in reply to:  4 Changed 19 months ago by Burtannia

Replying to RyanGlScott: Hi, the steps to reproduce are following the yesod quick start guide, I was using yesod-postgres at the time rather than yesod-sqlite:

stack new project-name yesod-postgres && cd project-name

stack build yesod-bin cabal-install --install-ghc

stack build

website-0.0.0 is because I named the project "website", if you called it potato then that package would be potato-0.0.0.


Running it now is giving me a different error:

potato-0.0.0: build (lib + exe)
Preprocessing library potato-0.0.0...
[ 1 of 11] Compiling Settings         ( src\Settings.hs, .stack-work\dist\ca59d0
ab\build\Settings.o )

--  While building package potato-0.0.0 using:
      C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_1.24.2.0_ghc-8.
0.2.exe --builddir=.stack-work\dist\ca59d0ab build lib:potato exe:potato --ghc-o
ptions " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure (-1073740940)

I then get a dialog box telling me ghc has stopped working.


If I use the yesod-sqlite template rather than yesod-postgres I get the same seg fault as before:

emu-0.0.0: configure (lib + exe)
Configuring emu-0.0.0...
emu-0.0.0: build (lib + exe)
Preprocessing library emu-0.0.0...
[ 1 of 11] Compiling Settings         ( src\Settings.hs, .stack-work\dist\ca59d0
ab\build\Settings.o )
[ 2 of 11] Compiling Settings.StaticFiles ( src\Settings\StaticFiles.hs, .stack-
work\dist\ca59d0ab\build\Settings\StaticFiles.o )
Segmentation fault/access violation in generated code

--  While building package emu-0.0.0 using:
      C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_1.24.2.0_ghc-8.
0.2.exe --builddir=.stack-work\dist\ca59d0ab build lib:emu exe:emu --ghc-options
 " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1

comment:6 Changed 19 months ago by Phyx-

Could you zip and attach the sample project. It's critical I can get a repro without stack.

comment:7 in reply to:  6 Changed 19 months ago by Burtannia

Replying to Phyx-:

Could you zip and attach the sample project. It's critical I can get a repro without stack.

I have zipped the postgres example and the sqlite example but they were too big to attach here. They are on dropbox at the following links:

Postgres: https://www.dropbox.com/s/nbt8yxmkjmt1h0u/postgresExample.zip?dl=0

Sqlite: https://www.dropbox.com/s/mmjqxt49zw29mj3/sqliteExample.zip?dl=0

comment:8 Changed 18 months ago by RyanGlScott

Thanks Burtannia. I tried building each of these examples with both GHC 8.0.2 and 8.2.1. Neither example segfaulted on GHC 8.2.1. On GHC 8.0.2, the postgres example didn't segfault, but the sqlite example did:

$ cabal build
Preprocessing library for sqliteExample-0.0.0..
Building library for sqliteExample-0.0.0..
[ 1 of 11] Compiling Settings         ( src\Settings.hs, dist\build\Settings.o )
[ 2 of 11] Compiling Settings.StaticFiles ( src\Settings\StaticFiles.hs, dist\build\Settings\StaticFiles.o )
[ 3 of 11] Compiling Model            ( src\Model.hs, dist\build\Model.o )
[ 4 of 11] Compiling Import.NoFoundation ( src\Import\NoFoundation.hs, dist\build\Import\NoFoundation.o )
[ 5 of 11] Compiling Foundation       ( src\Foundation.hs, dist\build\Foundation.o )
Segmentation fault/access violation in generated code

Running cabal build after this causes the build to succeed. However, cabal clean-ing and re-running cabal build causes the segfault to resurface:

$ cabal build
Preprocessing library for sqliteExample-0.0.0..
Building library for sqliteExample-0.0.0..
[ 1 of 11] Compiling Settings         ( src\Settings.hs, dist\build\Settings.o )
[ 2 of 11] Compiling Settings.StaticFiles ( src\Settings\StaticFiles.hs, dist\build\Settings\StaticFiles.o )
Segmentation fault/access violation in generated code

Notice that it appeared to segfault in a different location that time! Moreover, you appear to need to build these modules in parallel (cabal build's default behavior) to trigger the segfault (at least, on my 64-bit Windows 10 machine), since I can't get it to segfault with cabal build -j1.

My initial hunch is that this is an occurrence of #13112, since both Foundation and Settings.StaticFiles use quite a bit of Template Haskell.

comment:9 Changed 18 months ago by RyanGlScott

Status: infoneedednew

comment:10 Changed 11 months ago by RyanGlScott

Status: newinfoneeded

Burtannia, do you still experience this isssue with postgresql-libpq-0.9.4.1? That release contains a workaround for a very similar issue, so I'm curious to see if that fixes this as well.

comment:11 Changed 10 months ago by RyanGlScott

Resolution: invalid
Status: infoneededclosed

I'm going to close this since someone else reported that the exact same setup (i.e., a project that uses the same Settings.StaticFiles file) no longer segfaults with postgresql-libpq-0.9.4.1. Please reopen if this persists even after using that version of the library.

Note: See TracTickets for help on using tickets.