Subject: [PATCH] uvm_map.c
To: None <netbsd-bugs@netbsd.org, port-m68k@netbsd.org, port-sun3@netbsd.org>
From: J. Scott Kasten <jsk@titan.tetracon-eng.net>
List: netbsd-bugs
Date: 02/29/2000 18:42:37
Greetings.
I'm a NetBSD newbie. I recently installed 1.4 for arch Sun3 on a Sun3/80
(MC68030) with 16MB ram with 1Gig HD. When the machine was under heavy load
compiling c++ code, I was periodically getting a kernel panic:
"Panic: Malloc: out of space in kmem_map"
After recompiling the kernal with both egcs and gcc-2.7.2.3 and playing with
the hardware, I finally convinced myself due to the consistency of the error
that this was neither a freak hardware problem, nor a kernel compile problem.
I researched the archives, and the port-m68k list in May of 1999 had discussion
about exactly this type of issue from Chuck Cranor and Ken Nakata. Chuck
found an issue with pointer wrap around in uvm_amap.c. His patch was applied
back at release 1.9 of the file. I verified that his patch was still in the
current release, however, I was still having the problem. This indicated to
me that there must be other places where this can happen.
I beleive that I found one such place in uvm_map.c release 1.36.2.1. After
inserting a one line conditional for the wrap problem and recompiling the
kernel, I am pleased to say that I have not seen the error in over 4 days
now. I've kept the box compiling c++ code or otherwise abusing it for
the entire 4 days, 24 hours a day. I was getting the problem every 4 to
8 hours before. Therefore, I beleive the problem is fixed and offer the
enclosed diff to the port maintainers for consideration.
(There is a second spot in uvm_map.c that appears similar to the one
I patched, however, the outer code block seems to have sufficient
conditionals to avoid the problem there, so I left it untouched.
This second block is much further down in the file from the patch.)
*** uvm_map.c.orig Fri Feb 25 21:03:18 2000
--- uvm_map.c Fri Feb 25 21:10:10 2000
***************
*** 1671,1676 ****
--- 1671,1677 ----
if (uvm_map_lookup_entry(map, start, &entry)) {
UVM_MAP_CLIP_START(map, entry, start);
+ if (end >= start)
UVM_MAP_CLIP_END(map, entry, end); /* to be safe */
}
else {
--
J. Scott Kasten
jsk AT tetracon-eng DOT net
"That wasn't an attack. It was preemptive retaliation!"