Hi Bob,

You prompted me to google around a bit more for valid use cases of MAP_FIXED 
and here is an enlightening StackOverflow post:

https://stackoverflow.com/questions/28575893/when-would-one-use-mmap-map-fixed

So apparently the Autoconf's test doesn’t do anything wrong, but valid use 
cases for MAP_FIXED are indeed very special.

Is it fair to discard the mmap implementation completely, just because 
MAP_FIXED is failing? Maybe define something like HAVE_MMAP_MAP_FIXED instead 
(or not?)… Happy to do any tests on AIX if helpful.

All the best,
Yury

> On 28. Jul 2024, at 21:18, Bob Friesenhahn <graphicsmagick.proj...@gmail.com> 
> wrote:
> 
> I would not expect MAP_FIXED to be portable or a normal requirement. Most 
> common uses of memory mapping (e.g. file mapping) do not require a fixed 
> mapping. Perhaps device drivers with a user-space component (or applications 
> which store pointers in shared memory) might desire a fixed mapping 
> 
> Bob
> On Jul 28, 2024, at 8:11 AM, "Yury V. Zaytsev" <y...@shurup.com> wrote: 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
          • ... Brooks Davis

Reply via email to