Re: Writing to mmaped region cause segfault

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Otto Moerbeek
Date: Wednesday, November 3, 2010 - 5:12 am

On Wed, Nov 03, 2010 at 01:18:51PM +0200, Alexey Suslikov wrote:


This (complete!) program does not show the behahaviour. Please post a
complete testcase. Did you include sys/mman.h?

	-Otto

#include <sys/types.h>
#include <sys/mman.h>

#include <err.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>


int
main()
{
	int fd;
	char *buf;
	size_t len;

	fd = open("file", O_RDWR, 0);
	if (fd == -1)
		err(1, NULL);

	len = 16384;
    	buf = mmap(NULL, len + 1, PROT_READ | PROT_WRITE, MAP_PRIVATE,
	    fd, (off_t)0);
	if (buf == MAP_FAILED)
		err(1, NULL);
	buf[len] = '\0';
}
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Writing to mmaped region cause segfault, Alexey Suslikov, (Wed Nov 3, 4:18 am)
Re: Writing to mmaped region cause segfault, Otto Moerbeek, (Wed Nov 3, 5:12 am)
Re: Writing to mmaped region cause segfault, Otto Moerbeek, (Wed Nov 3, 5:23 am)
Re: Writing to mmaped region cause segfault, Alexey Suslikov, (Wed Nov 3, 5:33 am)
Re: Writing to mmaped region cause segfault, Otto Moerbeek, (Wed Nov 3, 6:47 am)
Re: Writing to mmaped region cause segfault, Ariane van der Steldt, (Wed Nov 3, 6:59 am)
Re: Writing to mmaped region cause segfault, Ted Unangst, (Wed Nov 3, 9:44 am)