yesodweb / yesod

A RESTful Haskell web framework built on WAI.
http://www.yesodweb.com/
MIT License
2.63k stars 370 forks source link

stack exec -- yesod devel for yesod-mysql crashes with ExitFailure (-11) #1531

Open ianchanning opened 6 years ago

ianchanning commented 6 years ago

Your OS name and version

Fedora 28

The versions of tools you're using (e.g. stack, yesod ghc).

stack v1.7.1, yesod v1.6, ghc 8.2.2

The versions of dependencies you're using

This is from the package.yaml:

dependencies:

# Due to a bug in GHC 8.0.1, we block its usage
# See: https://ghc.haskell.org/trac/ghc/ticket/12130
- base >=4.8.2.0 && <4.9 || >=4.9.1.0 && <5
- yesod >=1.6 && <1.7
- yesod-core >=1.6 && <1.7
- yesod-auth >=1.6 && <1.7
- yesod-static >=1.6 && <1.7
- yesod-form >=1.6 && <1.7
- classy-prelude >=1.4 && <1.5
- classy-prelude-conduit >=1.4 && <1.5
- classy-prelude-yesod >=1.4 && <1.5
- bytestring >=0.9 && <0.11
- text >=0.11 && <2.0
- persistent >=2.8 && <2.9
- persistent-mysql >=2.8 && <2.9
- mysql >= 0.1.4
- persistent-template >=2.5 && <2.9
- template-haskell
- shakespeare >=2.0 && <2.1
- hjsmin >=0.1 && <0.3
- monad-control >=0.3 && <1.1
- wai-extra >=3.0 && <3.1
- yaml >=0.8 && <0.9
- http-client-tls >=0.3 && <0.4
- http-conduit >=2.3 && <2.4
- directory >=1.1 && <1.4
- warp >=3.0 && <3.3
- data-default
- aeson >=0.6 && <1.4
- conduit >=1.0 && <2.0
- monad-logger >=0.3 && <0.4
- fast-logger >=2.2 && <2.5
- wai-logger >=2.2 && <2.4
- file-embed
- safe
- unordered-containers
- containers
- vector
- time
- case-insensitive
- wai
- foreign-store

For your convenience, we recommend pasting this script into bash and uploading the output as a gist...

Output here: https://gist.github.com/ianchanning/c651c1c8435b0423100a47ea36445e4f

Is there anything custom or unusual about your setup? i.e. new or prerelease versions of GHC, stack, etc.

Not that I'm aware of

Finally, if possible, please reproduce the error in a small script

I have listed the commands that I ran below, it is just trying to run the quickstart but for MySQL.

I had installed mariadb:

$ sudo dnf install mariadb mariadb-server
$ sudo systemctl start mariadb
$ sudo mysql_secure_installation
$ sudo systemctl enable mariadb
$ sudo firewall-cmd --permanent --add-port=3306/tcp
$ sudo firewall-cmd --add-port=3306/tcp
$ sudo dnf install mariadb-devel

Created the database:

mysql> CREATE DATABASE loot;
mysql> GRANT ALL PRIVILEGES ON loot.* TO "loot"@"localhost" IDENTIFIED BY "my special pass phrase";
mysql> FLUSH PRIVILEGES;

Here are the commands that I ran and then the error message I get when running

$ stack new loot yesod-mysql 
$ cd loot
$ stack install yesod-bin --install-ghc
$ sudo dnf install pcre-devel
$ stack build
$ export YESOD_MYSQL_PASSWORD="my special pass phrase"
$ stack exec -- yesod devel
Yesod devel server. Enter 'quit' or hit Ctrl-C to quit.
Application can be accessed at:

http://localhost:3000
https://localhost:3443
If you wish to test https capabilities, you should set the following variable:
  export APPROOT=https://localhost:3443

loot-0.0.0: unregistering (local file changes: templates/default-layout.lucius templates/homepage.julius templates/homepage.lucius)
loot-0.0.0: build (lib)
Preprocessing library for loot-0.0.0..
Building library for loot-0.0.0..
loot-0.0.0: copy/register
Installing library in /var/www/vhosts/loot/.stack-work/install/x86_64-linux-tinfo6/lts-11.15/8.2.2/lib/x86_64-linux-ghc-8.2.2/loot-0.0.0-7rtwPN3pOjM1yNxUV83Uju
Registering library for loot-0.0.0..
ExitSuccess
Type help for available commands. Press enter to force a rebuild.
Starting devel application
Unexpected: child process exited with ExitFailure (-11)
Trying again
Starting devel application
Unexpected: child process exited with ExitFailure (-11)
Trying again
Starting devel application
Unexpected: child process exited with ExitFailure (-11)
Trying again
Starting devel application
Unexpected: child process exited with ExitFailure (-11)
Trying again
Starting devel application
^Cyesod: Received ExitFailure (-2) when running
Raw command: stack build --fast --file-watch loot:lib --exec "/home/ian/.stack/snapshots/x86_64-linux-tinfo6/lts-11.15/8.2.2/bin/yesod devel-signal" --flag loot:dev --flag loot:library-only

There is also one other user who has seen a similar problem on Fedora 27 on Stack Overflow.

paul-rouse commented 6 years ago

I think this must be specific to Fedora: I am able to build and run without any problems on Ubuntu 16.04 using stack 1.7.1 and ghc 8.2.2, and running against MySQL 5.7.22.

Can you get any further idea what it is trying to do when it fails? To simplify things, you can run the binary stand-alone without yesod devel - for example run stack exec loot. On its own, I think that will just produce the "Unexpected: child process exited with ExitFailure (-11)" message, but you can try the same thing with strace to see if it is getting as far as attempting a database connection - maybe limit it to network calls, as in strace -e trace=network stack exec loot.

ianchanning commented 6 years ago

@paul-rouse, ok thanks. I'll have a try tonight.

ianchanning commented 6 years ago

Commands were pretty fatal:

[ian@localhost loot]$ stack exec loot
Segmentation fault (core dumped)
[ian@localhost loot]$ strace -e trace=network stack exec loot
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=23416, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 23
connect(23, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 23
connect(23, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
socket(AF_UNIX, SOCK_STREAM, 0)         = 23
connect(23, {sa_family=AF_UNIX, sun_path="/var/lib/mysql/mysql.sock"}, 110) = 0
setsockopt(23, SOL_IP, IP_TOS, [8], 4)  = -1 EOPNOTSUPP (Operation not supported)
setsockopt(23, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
recvfrom(23, "Y\0\0\0\n5.5.5-10.2.15-MariaDB\0\16\0\0\0s"..., 16384, MSG_DONTWAIT, NULL, NULL) = 93
sendto(23, "\301\0\0\1\214\242\236\0\0\0\0@!\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 197, MSG_DONTWAIT|MSG_NOSIGNAL, NULL, 0) = 197
recvfrom(23, "\20\0\0\2\0\0\0\2@\0\0\0\7\1\5\4loot", 16384, MSG_DONTWAIT, NULL, NULL) = 20
sendto(23, ",\0\0\0\3SET SESSION sql_mode = 'STR"..., 48, MSG_DONTWAIT|MSG_NOSIGNAL, NULL, 0) = 48
recvfrom(23, 0x351f5f0, 16384, MSG_DONTWAIT, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
recvfrom(23, "\7\0\0\1\0\0\0\2\0\0\0", 16384, MSG_DONTWAIT, NULL, NULL) = 11
setsockopt(23, SOL_SOCKET, SO_RCVTIMEO, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 0
setsockopt(23, SOL_SOCKET, SO_SNDTIMEO, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 0
sendto(23, "\21\0\0\0\3SET autocommit=0", 21, MSG_DONTWAIT|MSG_NOSIGNAL, NULL, 0) = 21
recvfrom(23, "\7\0\0\1\0\0\0\0\0\0\0", 16384, MSG_DONTWAIT, NULL, NULL) = 11
sendto(23, "\22\0\0\0\3start transaction", 22, MSG_DONTWAIT|MSG_NOSIGNAL, NULL, 0) = 22
recvfrom(23, "\7\0\0\1\0\0\0\1\0\0\0", 16384, MSG_DONTWAIT, NULL, NULL) = 11
sendto(23, "\251\0\0\0\3SELECT COLUMN_NAME, IS_NULL"..., 173, MSG_DONTWAIT|MSG_NOSIGNAL, NULL, 0) = 173
recvfrom(23, 0x351f5f0, 16384, MSG_DONTWAIT, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
recvfrom(23, "\1\0\0\1\4L\0\0\2\3def\22information_schema"..., 16384, MSG_DONTWAIT, NULL, NULL) = 345
sendto(23, "\362\0\0\0\3SELECT COLUMN_NAME, IS_NULL"..., 246, MSG_DONTWAIT|MSG_NOSIGNAL, NULL, 0) = 246
recvfrom(23, 0x351f5f0, 16384, MSG_DONTWAIT, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
recvfrom(23, "\1\0\0\1\10L\0\0\2\3def\22information_schema"..., 16384, MSG_DONTWAIT, NULL, NULL) = 707
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x44a6bd84} ---
+++ killed by SIGSEGV (core dumped) +++
Segmentation fault (core dumped)

About the only thing I can tell from that is that it looks like it found the mysql socket ok:

connect(23, {sa_family=AF_UNIX, sun_path="/var/lib/mysql/mysql.sock"}, 110) = 0
paul-rouse commented 6 years ago

I am able to reproduce this now, so I will continue to try to scope it.

hhefesto commented 6 years ago

I also have this problem (just updated from fedora 26 to 28). My previous problem was with libmysqlclient and it was fixed with (don't know if this helps): ln -s /usr/lib64/libmariadb.so /usr/lib64/libmysqlclient.so.18

akilegaspi commented 5 years ago

I'm getting this error also on Debian unstable using mariadb

akilegaspi commented 5 years ago

I was investigating this one, I can actually run stack exec <app name> but when using the devel server, I was getting ExitFailure (-11), I'm hoping there's a better way to debug this.

kebp commented 5 years ago

I appear to be encountering this error on Arch once I'd updated from mariadb 10.1.37 to 10.3.12.