mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [BUG] mm deadlock
@ 2002-05-09  3:21 TeJun Huh
  0 siblings, 0 replies; only message in thread
From: TeJun Huh @ 2002-05-09  3:21 UTC (permalink / raw)
  To: linux-kernel

 Running the following program on linux 2.4.18 SMP results in lockup
of the thread and some part of the system (any attempt to access the
thread list results in the lockup of the attempting thread).

 The program basically mmaps memory until the mmapped region is very
close to the bottom of the stack with some unmapped region inbetween.
Then it tries to access region beyond the end of the highest mmaped
region. I think it has something to do with stack growth.

---- program follows ----

#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>

#define BASE_SIZE	(32 << 20)
#define MIN_SIZE	(512 << 10)

int main(void)
{
	size_t size;
	unsigned long *p, *lastp;
	size_t last_size;
	int i;

	lastp = NULL;
	size = BASE_SIZE;
	while (size >= MIN_SIZE) {
		p = mmap(0, size, PROT_READ|PROT_WRITE,
			 MAP_SHARED|MAP_ANONYMOUS, 0, 0);
		if (p == (unsigned long *)-1)
			size >>= 1;
		else {
			lastp = p;
			last_size = size;
		}
	}

	p = lastp + last_size / sizeof(unsigned long);
	for (i = 0; i < last_size / sizeof(unsigned long); i++)
		p[i] = i;

	printf("ok\n");
	return 0;
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-05-09  3:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-09  3:21 [BUG] mm deadlock TeJun Huh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®