public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* munmap bug test program
@ 2003-09-30  2:11 peter garrone
  2003-09-30 14:39 ` Corinna Vinschen
  0 siblings, 1 reply; 9+ messages in thread
From: peter garrone @ 2003-09-30  2:11 UTC (permalink / raw)
  To: cygwin

This test program highlights the recent munmap problem addressed by Corinna.
It works with the updated mmap, and with linux, fails on cygwin with the prior mmap.

/**
 * mmap test.
 * mmaps two chunks of adjacent memory, then munmaps one and a half,
 * then sees if the remainder is still useable.
 */

#include <unistd.h>
#include <sys/mman.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fcntl.h>
#include <string.h>

#ifndef _POSIX_MAPPED_FILES
#warning Testing mmap/munmap, but _POSIX_MAPPED_FILES not defined.
#endif

#define CHUNKSIZE 0x10000

#undef Dim
#define Dim(x) ((int)(sizeof(x)/sizeof(x[0])))
void * mapping1,*mapping2;
char buff[CHUNKSIZE*4];
int main()
{
	int fd;
	int r;
	int temp_open_flags;
	char name[] = "test_cygwin_munmapXXXXXX";
	fd = mkstemp(name);
	assert(fd != -1);
	temp_open_flags = fcntl(fd, F_GETFL);
	assert(temp_open_flags != -1);
	assert((temp_open_flags & O_RDWR) == O_RDWR);

	/* Have to write to the file for mapping to work. */
	r = write(fd, buff, sizeof(buff));
	assert(r == sizeof(buff));


	mapping1 = mmap(0, 2*CHUNKSIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
	assert(mapping1 != MAP_FAILED);

	mapping2 = mmap(mapping1 + 2*CHUNKSIZE, 2*CHUNKSIZE, 
			PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, fd, 2*CHUNKSIZE);

	if(mapping2 == MAP_FAILED)
	{
		printf("OS wont do contiguous memory file mappings. Cant do test. Try changing CHUNKSIZE\n");
		munmap(mapping1, 2*CHUNKSIZE);
		close(fd);
		unlink(name);
		exit(0);
	}

	printf("mappings: %x %x\n",mapping1,mapping2);

	/* Unmap from middle of first chunk to end of second chunk. */
	r = munmap(mapping1 + CHUNKSIZE, 3*CHUNKSIZE);
	assert(r == 0);

	/* now try setting the first half of the first chunk */
	memset(mapping1, 0, CHUNKSIZE);

	close(fd);

	/* Unmap the last bit, so hopefully the unlink of the temporary file will work. */
	r = munmap(mapping1, CHUNKSIZE);
	assert(r == 0);

	r = unlink(name);
	assert(r == 0);

	return 0;
}

-- 
______________________________________________
http://www.linuxmail.org/
Now with e-mail forwarding for only US$5.95/yr

Powered by Outblaze

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: munmap bug test program
  2003-09-30  2:11 munmap bug test program peter garrone
@ 2003-09-30 14:39 ` Corinna Vinschen
  0 siblings, 0 replies; 9+ messages in thread
From: Corinna Vinschen @ 2003-09-30 14:39 UTC (permalink / raw)
  To: cygwin

On Tue, Sep 30, 2003 at 10:06:11AM +0800, peter garrone wrote:
> This test program highlights the recent munmap problem addressed by Corinna.
> It works with the updated mmap, and with linux, fails on cygwin with the prior mmap.

What "updated" mmap are you talking about, your's or the one in CVS?

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: munmap bug test program
@ 2003-10-02  0:34 peter garrone
  0 siblings, 0 replies; 9+ messages in thread
From: peter garrone @ 2003-10-02  0:34 UTC (permalink / raw)
  To: cygwin

>On Tue, Sep 30, 2003 at 10:06:11AM +0800, peter garrone wrote:
>> This test program highlights the recent munmap problem addressed by Corinna.
>> It works with the updated mmap, and with linux, fails on cygwin with the prior mmap.
>
>What "updated" mmap are you talking about, your's or the one in CVS?

>Corinna

The one in CVS, I believe I tested it with the one I submitted as well.


-- 
______________________________________________
http://www.linuxmail.org/
Now with e-mail forwarding for only US$5.95/yr

Powered by Outblaze

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: munmap bug test program
  2003-10-01 11:33     ` Corinna Vinschen
@ 2003-10-01 13:18       ` Robert Collins
  0 siblings, 0 replies; 9+ messages in thread
From: Robert Collins @ 2003-10-01 13:18 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 798 bytes --]

On Wed, 2003-10-01 at 20:07, Corinna Vinschen wrote:
> On Wed, Oct 01, 2003 at 07:56:08PM +1000, Robert Collins wrote:
> > On Wed, 2003-10-01 at 17:13, Corinna Vinschen wrote:
> > 
> > > Thanks for clarifying.  It was the first time I got a testcase for
> > > something which works instead of for something which is broken.  That
> > > irritated me a bit :-)
> > 
> > I'd suggested to Peter offline that he send in a test case, to be added
> > to our regression suite...
> 
> I see.  Good idea.  Will you add it to the testsuite then?

Eventually :}. I need to update my dev environment to the 1.5.x codebase
to run it... I've let it bitrot a little. If you have the time, that
would be better.

Rob
-- 
GPG key available at: <http://members.aardvark.net.au/lifeless/keys.txt>.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: munmap bug test program
  2003-10-01 10:06   ` Robert Collins
@ 2003-10-01 11:33     ` Corinna Vinschen
  2003-10-01 13:18       ` Robert Collins
  0 siblings, 1 reply; 9+ messages in thread
From: Corinna Vinschen @ 2003-10-01 11:33 UTC (permalink / raw)
  To: cygwin

On Wed, Oct 01, 2003 at 07:56:08PM +1000, Robert Collins wrote:
> On Wed, 2003-10-01 at 17:13, Corinna Vinschen wrote:
> 
> > Thanks for clarifying.  It was the first time I got a testcase for
> > something which works instead of for something which is broken.  That
> > irritated me a bit :-)
> 
> I'd suggested to Peter offline that he send in a test case, to be added
> to our regression suite...

I see.  Good idea.  Will you add it to the testsuite then?

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: munmap bug test program
  2003-10-01  7:29 ` munmap " Corinna Vinschen
@ 2003-10-01 10:06   ` Robert Collins
  2003-10-01 11:33     ` Corinna Vinschen
  0 siblings, 1 reply; 9+ messages in thread
From: Robert Collins @ 2003-10-01 10:06 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 415 bytes --]

On Wed, 2003-10-01 at 17:13, Corinna Vinschen wrote:

> Thanks for clarifying.  It was the first time I got a testcase for
> something which works instead of for something which is broken.  That
> irritated me a bit :-)

I'd suggested to Peter offline that he send in a test case, to be added
to our regression suite...

Rob
-- 
GPG key available at: <http://members.aardvark.net.au/lifeless/keys.txt>.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: munmap bug test program
  2003-10-01  0:22 peter garrone
@ 2003-10-01  7:29 ` Corinna Vinschen
  2003-10-01 10:06   ` Robert Collins
  0 siblings, 1 reply; 9+ messages in thread
From: Corinna Vinschen @ 2003-10-01  7:29 UTC (permalink / raw)
  To: cygwin

On Wed, Oct 01, 2003 at 08:22:19AM +0800, peter garrone wrote:
> >On Tue, Sep 30, 2003 at 10:06:11AM +0800, peter garrone wrote:
> >> This test program highlights the recent munmap problem addressed by Corinna.
> >> It works with the updated mmap, and with linux, fails on cygwin with the prior mmap.
> >
> >What "updated" mmap are you talking about, your's or the one in CVS?
> >
> >Corinna
> 
> It works with both. I am using your fix, ie the one in CVS.

Thanks for clarifying.  It was the first time I got a testcase for
something which works instead of for something which is broken.  That
irritated me a bit :-)

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: munmap bug test program
  2003-10-01  0:26 peter garrone
@ 2003-10-01  0:52 ` peter garrone
  0 siblings, 0 replies; 9+ messages in thread
From: peter garrone @ 2003-10-01  0:52 UTC (permalink / raw)
  To: corinna-cygwin; +Cc: cygwin

I said this test program works with both my own and corinna's fix, but in fact I have only
actually tested it with corinna's fix, since I discarded my own.
-- 
______________________________________________
http://www.linuxmail.org/
Now with e-mail forwarding for only US$5.95/yr

Powered by Outblaze

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: munmap bug test program
@ 2003-10-01  0:26 peter garrone
  2003-10-01  0:52 ` peter garrone
  0 siblings, 1 reply; 9+ messages in thread
From: peter garrone @ 2003-10-01  0:26 UTC (permalink / raw)
  To: corinna-cygwin; +Cc: cygwin

I said this test program works with both my own and corinna's fix, but in fact I have only
actually tested it with corinna's fix, since I discarded my own.
-- 
______________________________________________
http://www.linuxmail.org/
Now with e-mail forwarding for only US$5.95/yr

Powered by Outblaze

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2003-10-02  0:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-30  2:11 munmap bug test program peter garrone
2003-09-30 14:39 ` Corinna Vinschen
2003-10-01  0:22 peter garrone
2003-10-01  7:29 ` munmap " Corinna Vinschen
2003-10-01 10:06   ` Robert Collins
2003-10-01 11:33     ` Corinna Vinschen
2003-10-01 13:18       ` Robert Collins
2003-10-01  0:26 peter garrone
2003-10-01  0:52 ` peter garrone
2003-10-02  0:34 peter garrone

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).