On Wed, Jan 20, 2021 at 04:54:26PM +0100, Christian Jullien wrote:
> Hum! I'm not convinced as don't do anything with returned memory block
> between mmap and munmap.
> The offending code is similar to munmap(mmap(...)) => coredump!
Sigh. You *are* doing something with the returned memory: unmapping it.
Again: MAP_FIXED will replace existing mappings. Think about it what
that means.
-Otto
>
>
> -----Original Message-----
> From: Mark Kettenis [mailto:[email protected]]
> Sent: Wednesday, January 20, 2021 15:53
> To: [email protected]
> Cc: [email protected]; [email protected]; [email protected]
> Subject: Re: munmap sometimes does coredump on arm after mmap success
>
> > Reply-To: <[email protected]>
> > From: "Christian Jullien" <[email protected]>
> >
> > I will no longer use MAP_FIXED on OpenBSD and accept that save/restore
> fails
> > on this system. It is a rather minor feature.
> >
> > Note for myself: I clearly accept that MAP_FIXED can fails to allocate at
> a
> > given address but, when succeeded I still don't understand why the address
> > range returned at this address does not entirely belong to my process and
> > nobody else even my own code can allocate something in that range.
> > IMHO munmap should never fail for an address returned by mmap.
>
> The munmap doesn't fail. It succeeds and unmaps bits of the address
> space that you're running on. You're pulling out the carpet from
> under your own feet! So you fall over and this results in a core dump.
>