[GHC] #13945: 'ghc-pkg update' fails due to bad file descriptor error
GHC
ghc-devs at haskell.org
Tue Aug 29 14:25:54 UTC 2017
#13945: 'ghc-pkg update' fails due to bad file descriptor error
---------------------------------+----------------------------------------
Reporter: mpickering | Owner: (none)
Type: bug | Status: new
Priority: high | Milestone: 8.2.2
Component: Compiler | Version: 8.2.1-rc3
Resolution: | Keywords:
Operating System: Linux | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
---------------------------------+----------------------------------------
Comment (by bgamari):
I am able to reproduce this locally. Here is a small reproducer,
{{{#!c
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
int main () {
int fd = open("libraries/bootstrapping.conf/package.cache.lock",
O_RDONLY|O_NOCTTY|O_NONBLOCK);
int res;
struct stat stat;
res = fstat(fd, &stat);
printf("stat: %s\n", strerror(errno));
res = flock(fd, LOCK_EX);
printf("flock: %s\n", strerror(errno));
res = flock(fd, LOCK_UN);
printf("funlock: %s\n", strerror(errno));
close(fd);
return 0;
}
}}}
When run in an NFS-mounted GHC tree with an existing lockfile this will
fail with,
{{{
$ gcc test.c && ./a.out
stat: Success
flock: Bad file descriptor
funlock: Bad file descriptor
}}}
Strangely if one changes `O_RDONLY` to `O_RDWR` the failure becomes,
{{{
$ gcc test.c && ./a.out
stat: Success
flock: No locks available
funlock: No locks available
}}}
So I think this may be in part due to the read-only nature of the fd, but
there may be more at play.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13945#comment:10>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list