possible problem with memory allocation using calloc/mmap/munmap

Corinna Vinschen corinna-cygwin@cygwin.com
Fri Jun 7 07:27:00 GMT 2019


On Jun  6 15:13, Stanislav Kascak wrote:
> > > [...]
> > > I played around a bit and I can confirm it would be consistent with
> > > current behavior:
> > > memwrite <0 - filesize) - no error, written to file
> > > memwrite <filesize - 4k) - no error, no file change
> > > memwrite <4k, 64k) - SIGSEGV
> > > memwrite <64k, mmap alloc size) - SIGSEGV or another mem alloc
> > > overwrite (depending on whether there is another allocation)
> > > With workaround last line would be fixed to SIGBUS (along with proper
> > > allocation length). I believe this is completely OK.
> > >
> > > >
> > > > > - is it possible that some subsequent mem alloc request would return
> > > > > region from |-- THE VOID 60K --| which could again cause segfault
> > > > > after munmap?
> > > >
> > > > No, as stated above.  Allocations are restricted to Windows' 64K
> > > > allocation granularity.
> > >
> > > I apologize. I missed that sentence. So, your workaround seems fine.
> >
> > Please try the latest snapshot from https://cygwin.com/snapshots/
> > Just replacing the Cygwin DLL is sufficient.
> 
> My test programs work fine and also openldap crash that led me to this
> issue is gone (openldap tests still fail, but on a different place
> after the one above and now with a SIGBUS which already gives a good
> hint as to where to look).
> I think your patch works quite well. Thanks a lot.

Thanks for testing!


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20190607/dc2d195a/attachment.sig>


More information about the Cygwin mailing list