Hi there,

I’m trying to wrap my head around AC_FUNC_MMAP failing on AIX (specifically, 
version 7.3 is what I tried on GCC compile farm). It appears that it has been 
failing for decades though, so the problem isn’t exactly new...

It returns exit code 10, which means that the following comparison fails:

  data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | 
MAP_FIXED, fd, 0L);

If I check the return value of mmap it equals to MAP_FAILED.

Now, the question is, why does it fail and is it supposed to fail or not? Here 
are the IBM docs on the subject:

  https://www.ibm.com/docs/en/aix/7.3?topic=m-mmap-mmap64-subroutine

It says 

  “A region is never placed ... at an address where it would overlap an 
existing region.”

(Linux has a similar comment in the man pages: “If the memory region ... 
overlaps pages of any existing mapping(s), then the overlapped part of the 
existing
mapping(s) will be discarded.” - macOS simply says MAP_FIXED is discouraged.)

This is the part that is confusing me. The test says explicitly:

  “Next, try to mmap the file at a fixed address which already has something 
else allocated at it.”

To me this sounds like it’s testing something, which actually shouldn’t work. 

However, on macOS at least it works (and obviously on other common systems, 
otherwise people would have noticed a long time ago) - so maybe I’m 
misunderstanding the comment.

If I remove MAP_FIXED, then the rest works (including data consistency checks). 
So apparently AIX has a working mmap implementation, except for this particular 
issue / flag.

Also it doesn’t just do some random nonsense, but returns MAP_FAILED. Thus 
well-written software should be checking for it anyway and act accordingly. The 
errorno is set to ENOMEM (“Not enough space”).

How would you go about that? I see the check has been adjusted several times 
lately, so hopefully Paul or Zack could chime in?

Is it a bug that IBM should fix? Obviously, didn’t happen so far, even though 
it has been the case for a very long while. Anyone has contacts and/or works 
for IBM?

Or maybe the test is not good and should be adjusted by either removing the 
MAP_FIXED flag or still succeeding upon MAP_FAILED?

P.S. I’m not subscribed to the list, so please keep me on CC.

All the best,
Yury




  • AC_FUNC_MMAP ... Yury V. Zaytsev
    • Re: AC_F... Yury V. Zaytsev
      • Re: ... Bob Friesenhahn
        • ... Paul Eggert
          • ... Bob Friesenhahn
            • ... Zack Weinberg
              • ... Yury V. Zaytsev
              • ... Bob Friesenhahn
                • ... Howard Chu via Discussion list for the autoconf build system
              • ... Paul Eggert
          • ... Yury V. Zaytsev

Reply via email to