Opened 15 years ago

Closed 5 years ago

Last modified 4 years ago

#3550 closed bug (fixed)

[mmap] Freezes when maping lots of memory

Reported by: Adek336 Owned by: nobody
Priority: normal Milestone: R1/beta2
Component: System/Kernel Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

Test program:

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

int main()
{
	char name[1024];
	strcpy(name, "/tmp/adipeXXXXXX");
	int fd = mkstemp(name);
	if (fd == -1)
	{
		perror("mkstemp");
		exit(1);
	}

	void *v;

	int i;
	for (i = 0; i < 4000000; i++)
	{
		v = mmap(NULL, 1000* getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
		fprintf(stderr, "i = %d\n", i);
		if (v == (caddr_t) -1)
		{
			perror("mmap");
			exit(1);
		}
	}


	close(fd);
        return 0;
}

On Haiku: the program freezes after i = 224, can't ctrl-c it, can't open the context menu when clicking on the cpu meter in Deskbar, the app doesn't close when Terminal is closed, the Shutdown dialog freezes, cpu meter in Deskbar shows 100%.

For comparison, on Linux: after some iterations, "mmap: Cannot allocate memory"

Tested under vmware, hrev29445, hybrid build, 524 MiB memory in the guest machine.

Change History (3)

comment:1 by axeld, 7 years ago

Owner: changed from axeld to nobody
Status: newassigned

comment:2 by waddlesplash, 5 years ago

Resolution: fixed
Status: assignedclosed

Here it gets to i=384 almost instantly and then exits cleanly with "mmap: Out of memory." So this is fixed.

comment:3 by nielx, 4 years ago

Milestone: R1R1/beta2

Assign tickets with status=closed and resolution=fixed within the R1/beta2 development window to the R1/beta2 Milestone

Note: See TracTickets for help on using tickets.