[Bug 254120] Linuxulator: getcwd returns ENOMEM instead of ERANGE

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Mon Mar 8 03:06:44 UTC 2021


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=254120

            Bug ID: 254120
           Summary: Linuxulator: getcwd returns ENOMEM instead of ERANGE
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs at FreeBSD.org
          Reporter: iwtcex at gmail.com

% cat getcwd.c 
#include <assert.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>

int main() {

  char buf[3];
  assert(getcwd(buf, sizeof(buf)) == NULL);
  if (errno != ERANGE) {    
    perror("getcwd");
  }

  return 0;
}
% pwd | wc -c
      29
% /compat/linux/bin/cc getcwd.c -o getcwd
% ./getcwd 
getcwd: Cannot allocate memory

On the Linux side getcwd is clearly documented to return ERANGE and
at least Mono actually expects it:
https://github.com/mono/mono/blob/da11592cbea4269971f4b1f9624769a85cc10660/mono/eglib/gfile-posix.c#L175.

This is mostly relevant for FNA/MonoGame applications.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list