[GHC] #12572: `readdir_r` is deprecated
#12572: `readdir_r` is deprecated -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Core | Version: 8.1 Libraries | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Building GHC Unknown/Multiple | failed Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- When building GHC git HEAD on Debian Testing I get: {{{ libraries/unix/cbits/HsUnix.c: In function ‘__hscore_readdir’: libraries/unix/cbits/HsUnix.c:64:3: error: error: ‘readdir_r’ is deprecated [-Werror=deprecated-declarations] res = readdir_r(dirPtr, p, pDirEnt); ^~~ In file included from libraries/unix/include/HsUnix.h:71:0: error: 0, from libraries/unix/cbits/HsUnix.c:9: /usr/include/dirent.h:183:12: error: note: declared here extern int readdir_r (DIR *__restrict __dirp, ^~~~~~~~~ }}} According to the man page:
This function is deprecated; use readdir(3) instead.
The readdir_r() function was invented as a reentrant version of readdir(3). It reads the next directory entry from the directory stream dirp, and returns it in the caller-allocated buffer pointed to by entry.
It is expected that a future version of POSIX.1 will make readdir_r() obsolete, and require that readdir() be thread-safe when concurrently employed on different directory streams.
In order to support all of the various *nix systems, we probably need to detect if `readdir_r` is deprecated and only use `readdir` where `readdir_r` is in fact deprecated. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12572> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12572: `readdir_r` is deprecated -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Building GHC | Unknown/Multiple failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by erikd): * owner: => erikd -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12572#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12572: `readdir_r` is deprecated -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Building GHC | Unknown/Multiple failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): Since the implementation already has `#if HAVE_READDIR_R` this fix mostly involves detecting whether `readdir_r` is deprecated or not and setting `HAVE_READDIR_R` appropriately. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12572#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12572: `readdir_r` is deprecated -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Building GHC | Unknown/Multiple failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rwbarton): Doesn't unix have its own bug tracker (https://github.com/haskell/unix/issues)? But then I wonder why there is a libraries/unix component here? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12572#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12572: `readdir_r` is deprecated -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Building GHC | Unknown/Multiple failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): Lodged a ticket at https://github.com/haskell/unix/issues/70. Should we keep this here to until the fix in the unix submodule is merged? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12572#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12572: `readdir_r` is deprecated -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Building GHC | Unknown/Multiple failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): This is now fixed in the unix git repo.@bgamari whats the process to get the GHC tree using the latest version on github? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12572#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12572: `readdir_r` is deprecated -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Building GHC | Unknown/Multiple failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ezyang): When I validate GHC with the latest version of unix, I get a segfault. {{{ *** Error in `/home/hs01/ezyang/ghc-validate/inplace/lib/bin/haddock': free(): invalid pointer: 0x00000000022f18e0 *** ======= Backtrace: ========= /usr/lib/libc.so.6(+0x70c4b)[0x7f0860463c4b] /usr/lib/libc.so.6(+0x76fe6)[0x7f0860469fe6] /usr/lib/libc.so.6(+0x777de)[0x7f086046a7de] /home/hs01/ezyang/ghc-validate/libraries/unix/dist- install/build/libHSunix-2.7.2.0-ghc8.1.20160 905.so(__hscore_free_dirent+0x9)[0x7f0863212010] /home/hs01/ezyang/ghc-validate/libraries/unix/dist- install/build/libHSunix-2.7.2.0-ghc8.1.20160 905.so(+0x97197)[0x7f08631d5197] }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12572#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12572: `readdir_r` is deprecated -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Building GHC | Unknown/Multiple failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ezyang): Bug looks very simple: {{{ commit 748e3224e06638639a76cbc622e9b8c17054d5df Author: Edward Z. Yang <ezyang@cs.stanford.edu> Date: Wed Sep 7 17:31:02 2016 -0700 Fix segfault from inconsistent macro use. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> diff --git a/cbits/HsUnix.c b/cbits/HsUnix.c index 08cccd5..7c72a34 100644 --- a/cbits/HsUnix.c +++ b/cbits/HsUnix.c @@ -110,7 +110,7 @@ char *__hscore_d_name( struct dirent* d ) void __hscore_free_dirent(struct dirent *dEnt) { -#if HAVE_READDIR_R +#if HAVE_READDIR_R && USE_READDIR_R free(dEnt); #endif } }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12572#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12572: `readdir_r` is deprecated -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Building GHC | Unknown/Multiple failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Edward Z. Yang <ezyang@…>): In [changeset:"a8238a4eb628dcab93e19021b27c0cf2b38ef7d0/ghc" a8238a4e/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="a8238a4eb628dcab93e19021b27c0cf2b38ef7d0" Update unix submodule to latest HEAD. Fixes readdir validation error (fixes #12572). Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12572#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12572: `readdir_r` is deprecated -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: merge Priority: normal | Milestone: Component: Core Libraries | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Building GHC | Unknown/Multiple failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by ezyang): * status: new => merge -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12572#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12572: `readdir_r` is deprecated -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: merge Priority: normal | Milestone: Component: Core Libraries | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Building GHC | Unknown/Multiple failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Sorry for missing your comment, erikd! Thanks for handling this Edward. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12572#comment:10> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12572: `readdir_r` is deprecated -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: closed Priority: normal | Milestone: 8.0.2 Component: Core Libraries | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Building GHC | Unknown/Multiple failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * version: 8.1 => 8.0.1 * resolution: => fixed * milestone: => 8.0.2 Comment: Merged to `ghc-8.0` as 96850ef96461df54862e5e9f53deb14145bd6925. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12572#comment:11> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC