Opened 10 years ago

Closed 6 months ago

#3550 closed bug (fixed)

[mmap] Freezes when maping lots of memory

Reported by: Adek336 Owned by: nobody
Priority: normal Milestone: R1
Component: System/Kernel Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no 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 (2)

comment:1 Changed 2 years ago by axeld

Owner: changed from axeld to nobody
Status: newassigned

comment:2 Changed 6 months ago by waddlesplash

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.

Note: See TracTickets for help on using tickets.