[MacPorts] #65569: emacs and legacy-support: `openat` broken?

MacPorts noreply at macports.org
Fri Sep 1 00:04:49 UTC 2023


#65569: emacs and legacy-support: `openat` broken?
-------------------------+-------------------------------------------------
  Reporter:  lemzwerg    |      Owner:  drkp
      Type:  defect      |     Status:  assigned
  Priority:  Normal      |  Milestone:
 Component:  ports       |    Version:
Resolution:              |   Keywords:  lion mountainlion snowleopard
      Port:  emacs       |  mavericks
  legacy-support         |
-------------------------+-------------------------------------------------

Comment (by acjones8):

 I've made some further progress. So - it turns out, the -2 for the file
 descriptor is actually correct, it's defined in `fcntl.h` and shows up
 when I tested it with a very simple C program that just calls it on its
 own source file. No issues here.

 By rebuilding legacy-support with -g and -O0, I was able to get GDB to
 step into legacy-support's implementation of `faccessat()`. The problem is
 on line 107:
 {{{
 ERR_ON(EINVAL, flags & ~AT_SYMLINK_NOFOLLOW);
 }}}

 `ERR_ON()` expands into:
 {{{
 #define ERR_ON(code, what)   if (what) { errno = (code); return -1; }
 }}}

 My understanding of what's going on here is that `ERR_ON` checks if the
 code in the 2nd argument evaluates to anything other than 0. If so, is
 sets errno to `EINVAL` and then returns -1. I'm able to confirm in
 `orig_faccessat()` that the result is indeed -1, and the program crashes
 in GDB as soon as I try to step through this line, so I'm pretty confident
 this is the source of the issue.

 The strange thing is, if I manually evaluate the code on the right
 (negating AT_SYMLINK_NOFOLLOW, which is defined as 32, and then anding it
 with the value of the flags argument, which is 16), I get 0, so this
 doesn't seem like it should be triggering.

-- 
Ticket URL: <https://trac.macports.org/ticket/65569#comment:9>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list