Opened 11 years ago

Closed 22 months ago

Last modified 4 months 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


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)

	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)

        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, 3 years ago

Owner: changed from axeld to nobody
Status: newassigned

comment:2 by waddlesplash, 22 months 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 months 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.