Skip to content

Cannot run on i386 Ubuntu. Fails file locking #6602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
newhoggy opened this issue Mar 22, 2020 · 15 comments
Closed

Cannot run on i386 Ubuntu. Fails file locking #6602

newhoggy opened this issue Mar 22, 2020 · 15 comments

Comments

@newhoggy
Copy link

newhoggy commented Mar 22, 2020

Describe the bug
Running cabal v2-update fails on i386-ubuntu-18.04 running in docker. It's possible that this is unrelated to docker although I've not tested this.

To Reproduce
Steps to reproduce the behavior:

$ docker pull quay.io/haskell_works/ghc-8.8.3:i386-ubuntu-18.04
$ docker run -ti quay.io/haskell_works/ghc-8.8.3:i386-ubuntu-18.04 bash
root@0bbe37ede319:/# cabal v2-update
Config file path source is default config file.
Config file /root/.cabal/config not found.
Writing default configuration to /root/.cabal/config
fdLock: invalid argument (Invalid argument)

Expected behavior
cabal v2-update should work on i386-ubuntu.

System information
Operating system: i386-ubuntu in docker (possible also not in docker)

$ cabal --version
cabal-install version 3.0.1.0
compiled using version 3.0.2.0 of the Cabal library

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.8.2

Additional context

$ strace cabal v2-update
.....
openat(AT_FDCWD, "/root/.cabal/packages/hackage.haskell.org/hackage-security-lock", O_RDWR|O_CREAT, 0666) = 11
fcntl64(11, F_OFD_SETLKW, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=662717783099834368}) = -1 EINVAL (Invalid argument)
close(11)                               = 0
poll([{fd=2, events=POLLOUT}], 1, 0)    = 1 ([{fd=2, revents=POLLOUT}])
write(2, "fdLock: invalid argument (Invali"..., 44fdLock: invalid argument (Invalid argument)
) = 44
@newhoggy
Copy link
Author

Currently, this is blocking me from setting up CI builds for https://github.com/erikd/wide-word/ on 32-bit Linux.

@newhoggy
Copy link
Author

Perhaps we shouldn't be using fcntl64 on 32-bit systems and need to fallback to fcntl?

@newhoggy
Copy link
Author

I've grepped for all occurrences of file descriptor 11:

$ cat stderr | grep '\<11\>'
openat(AT_FDCWD, "/proc/self/task/398/comm", O_RDWR) = 11
write(11, "cabal:w", 7)                 = 7
close(11)                               = 0
openat(AT_FDCWD, "/root/.cabal/config.tmp", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_LARGEFILE, 0666) = 11
fstat64(11, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
ftruncate64(11, 0)                      = 0
ioctl(11, TCGETS, 0xff806a68)           = -1 ENOTTY (Inappropriate ioctl for device)
write(11, "-- This is the configuration fil"..., 5343) = 5343
close(11)                               = 0
openat(AT_FDCWD, "/root/.cabal/config", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_LARGEFILE) = 11
fstat64(11, {st_mode=S_IFREG|0644, st_size=5343, ...}) = 0
ioctl(11, TCGETS, 0xff806a68)           = -1 ENOTTY (Inappropriate ioctl for device)
read(11, "-- This is the configuration fil"..., 8192) = 5343
read(11, "", 8192)                      = 0
close(11)                               = 0
openat(AT_FDCWD, "/", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC|O_DIRECTORY) = 11
fstat64(11, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
getdents64(11, /* 23 entries */, 32768) = 584
getdents64(11, /* 0 entries */, 32768)  = 0
close(11)                               = 0
openat(AT_FDCWD, "/.", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC|O_DIRECTORY) = 11
fstat64(11, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
getdents64(11, /* 23 entries */, 32768) = 584
getdents64(11, /* 0 entries */, 32768)  = 0
close(11)                               = 0
openat(AT_FDCWD, "/etc/host.conf", O_RDONLY|O_CLOEXEC) = 11
fstat64(11, {st_mode=S_IFREG|0644, st_size=92, ...}) = 0
read(11, "# The \"order\" line is only used "..., 4096) = 92
read(11, "", 4096)                      = 0
close(11)                               = 0
openat(AT_FDCWD, "/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 11
fstat64(11, {st_mode=S_IFREG|0644, st_size=68, ...}) = 0
read(11, "# This file is included on the m"..., 4096) = 68
read(11, "", 4096)                      = 0
close(11)                               = 0
socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 11
connect(11, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("192.168.65.1")}, 16) = 0
poll([{fd=11, events=POLLOUT}], 1, 0)   = 1 ([{fd=11, revents=POLLOUT}])
send(11, "hp\1\0\0\1\0\0\0\0\0\1\10_MIRRORS\7HACKAGE\7HA"..., 57, MSG_NOSIGNAL) = 57
poll([{fd=11, events=POLLIN}], 1, 5000) = 1 ([{fd=11, revents=POLLIN}])
recvfrom(11, "hp\201\200\0\1\0\1\0\0\0\0\10_MIRRORS\7HACKAGE\7HA"..., 65536, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("192.168.65.1")}, [28->16]) = 159
close(11)                               = 0
openat(AT_FDCWD, "/root/.cabal/packages/hackage.haskell.org/root396-0.json", O_RDWR|O_CREAT|O_EXCL|O_NOCTTY|O_NONBLOCK|O_LARGEFILE, 0666) = 11
fstat64(11, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
ioctl(11, TCGETS, 0xff806a68)           = -1 ENOTTY (Inappropriate ioctl for device)
write(11, "{\n  \"signatures\": [\n    {\n      "..., 4077) = 4077
close(11)                               = 0
openat(AT_FDCWD, "/root/.cabal/packages/hackage.haskell.org/root396-0.json", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_LARGEFILE) = 11
fstat64(11, {st_mode=S_IFREG|0644, st_size=4077, ...}) = 0
ioctl(11, TCGETS, 0xff806a68)           = -1 ENOTTY (Inappropriate ioctl for device)
read(11, "{\n  \"signatures\": [\n    {\n      "..., 32760) = 4077
read(11, "", 32760)                     = 0
close(11)                               = 0
openat(AT_FDCWD, "/root/.cabal/packages/hackage.haskell.org/hackage-security-lock", O_RDWR|O_CREAT, 0666) = 11
fcntl64(11, F_OFD_SETLKW, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=-599317077899083776}) = -1 EINVAL (Invalid argument)
close(11)                               = 0
openat(AT_FDCWD, "/root/.cabal/packages/hackage.haskell.org/root396-3.json", O_RDWR|O_CREAT|O_EXCL|O_NOCTTY|O_NONBLOCK|O_LARGEFILE, 0666) = 11
fstat64(11, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
ioctl(11, TCGETS, 0xff806a68)           = -1 ENOTTY (Inappropriate ioctl for device)
write(11, "{\n  \"signatures\": [\n    {\n      "..., 4077) = 4077
close(11)                               = 0
openat(AT_FDCWD, "/root/.cabal/packages/hackage.haskell.org/root396-3.json", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_LARGEFILE) = 11
fstat64(11, {st_mode=S_IFREG|0644, st_size=4077, ...}) = 0
ioctl(11, TCGETS, 0xff806a68)           = -1 ENOTTY (Inappropriate ioctl for device)
read(11, "{\n  \"signatures\": [\n    {\n      "..., 32760) = 4077
read(11, "", 32760)                     = 0
close(11)                               = 0
openat(AT_FDCWD, "/root/.cabal/packages/hackage.haskell.org/hackage-security-lock", O_RDWR|O_CREAT, 0666) = 11
fcntl64(11, F_OFD_SETLKW, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=7220171123604848640}) = -1 EINVAL (Invalid argument)
close(11)                               = 0
openat(AT_FDCWD, "/root/.cabal/packages/hackage.haskell.org/root396-6.json", O_RDWR|O_CREAT|O_EXCL|O_NOCTTY|O_NONBLOCK|O_LARGEFILE, 0666) = 11
fstat64(11, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
ioctl(11, TCGETS, 0xff806a68)           = -1 ENOTTY (Inappropriate ioctl for device)
write(11, "{\n  \"signatures\": [\n    {\n      "..., 4077) = 4077
close(11)                               = 0
openat(AT_FDCWD, "/root/.cabal/packages/hackage.haskell.org/root396-6.json", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_LARGEFILE) = 11
fstat64(11, {st_mode=S_IFREG|0644, st_size=4077, ...}) = 0
ioctl(11, TCGETS, 0xff806a68)           = -1 ENOTTY (Inappropriate ioctl for device)
read(11, "{\n  \"signatures\": [\n    {\n      "..., 32760) = 4077
read(11, "", 32760)                     = 0
close(11)                               = 0
openat(AT_FDCWD, "/root/.cabal/packages/hackage.haskell.org/hackage-security-lock", O_RDWR|O_CREAT, 0666) = 11
fcntl64(11, F_OFD_SETLKW, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=-604673292959219712}) = -1 EINVAL (Invalid argument)
close(11)                               = 0

@newhoggy
Copy link
Author

This is interesting:

root@0bbe37ede319:/# cat stderr | grep fcntl | grep EINVAL
fcntl64(11, F_OFD_SETLKW, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=-599317077899083776}) = -1 EINVAL (Invalid argument)
fcntl64(11, F_OFD_SETLKW, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=7220171123604848640}) = -1 EINVAL (Invalid argument)
fcntl64(11, F_OFD_SETLKW, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=-604673292959219712}) = -1 EINVAL (Invalid argument)

Everywhere fcntl64 fails, l_len is set to a ridiculous number.

@phadej
Copy link
Collaborator

phadej commented Mar 22, 2020

Please, could you buffer your investigation and post them at once. The mail noise is bad.

@newhoggy
Copy link
Author

On 64-bit Linux, cabal doesn't even invoke fcntl64, but also the arguments it passes onto fcntl are sensible.

$ cat stderr | grep '\(F_OFD_SETLK\|AT_FDCWD\)' | grep -A 3 /root/.cabal/packages/hackage.haskell.org/hackage-security-lock
openat(AT_FDCWD, "/root/.cabal/packages/hackage.haskell.org/hackage-security-lock", O_RDWR|O_CREAT, 0666) = 11
fcntl(11, F_OFD_SETLKW, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
fcntl(11, F_OFD_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0

@phadej
Copy link
Collaborator

phadej commented Mar 22, 2020

The relevant file is https://github.com/phadej/lukko/blob/master/src-ofd/Lukko/OFD.hsc#L147-L179

I don't see how l_len can turn into something non-zero. Looks like i386 stuff didn't set the field when calling to fcntl64.

@newhoggy
Copy link
Author

newhoggy commented Mar 22, 2020

Been trying to build hackage-security on i386, but have been failing with cabal so I'm resorting to stack.

When using stack I saw this:

$ /root/.local/bin/stack build hackage-security
...
[36 of 43] Compiling Hackage.Security.Trusted
/usr/bin/ld.gold: fatal error: .stack-work/dist/i386-linux/Cabal-2.4.0.1/build/Hackage/Security/Trusted.o: Value too large for defined data type
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
Completed 12 action(s).

--  While building package hackage-security-0.6.0.0 using:
      /root/.stack/setup-exe-cache/i386-linux/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5 --builddir=.stack-work/dist/i386-linux/Cabal-2.4.0.1 build lib:hackage-security --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

Why would the linker fail like that?

This is the stack.yaml I used:

$ cat stack.yaml
resolver: lts-14.27
packages:
- example-client
- hackage-repo-tool
- hackage-root-tool
- hackage-security
- hackage-security-HTTP
- hackage-security-curl
- hackage-security-http-client
- precompute-fileinfo
extra-deps:
- http-client-0.5.5
- lukko-0.1.1.1

@phadej
Copy link
Collaborator

phadej commented Mar 23, 2020

The issue is tracked in haskellari/lukko#15

One solution is to compile lukko -ofd-locking. I'm resisting adding configure script to to lukko, but I guess I should do that :( looks like OFD locking wasn't that popular that bugs were fixed more universally.

@newhoggy
Copy link
Author

I've confirmed the above work around works for me.

@phadej phadej closed this as completed Mar 23, 2020
@newhoggy
Copy link
Author

newhoggy commented Mar 29, 2020

Even though there is a workaround, I think perhaps this issue should be re-opened because it remains the case that the version of cabal available for download has this problem and it would be good to have a new release with this fixed so I can undo all the patches I've made in my CI environment.

@simonmichael
Copy link

This happened to me today (installed cabal-3.2.0.0 from hackage using cabal-3.0.0.0). I'm trying to work around it like so, and failing:

$ cabal install -w ghc-8.8.3 cabal-install --constraint 'lukko -ofd-locking'
Resolving dependencies...
Build profile: -w ghc-8.8.3 -O1
In order, the following will be built (use -v for more details):
 - lukko-0.1.1.2 (lib) (requires build)
 - hackage-security-0.6.0.1 (lib) (requires build)
 - cabal-install-3.2.0.0 (exe:cabal) (requires build)
Starting     lukko-0.1.1.2 (lib)
Building     lukko-0.1.1.2 (lib)
Installing   lukko-0.1.1.2 (lib)
cabal: Failed to build lukko-0.1.1.2 (which is required by
cabal-install-3.2.0.0). The failure occurred during the final install step.
The exception was:
fdTryLock: invalid argument (Invalid argument)

@simonmichael
Copy link

I was using the faulty cabal-install to rebuild lukko. An older one worked:

$ cabal-3.0.0.0 install -w ghc88 cabal-install --constraint 'lukko -ofd-locking'
$ cabal update  # success

So, worked around, but it wasn't pleasant, and I too think this issue is important.

@ghost
Copy link

ghost commented Aug 1, 2020

Slackware 14.2 (32 bit)
ghc-8.6.5
cabal-install-3.2.0.0

bash-4.3$ ~/.cabal/bin/cabal v2-update
fdLock: invalid argument (Invalid argument)
bash-4.3$

@hasufell
Copy link
Member

hasufell commented Oct 9, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants