Bug 30164

Summary: Machine hangs on swap problems.
Product: Base System Reporter: Peter <pb.ludd.luth.se>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.3-RELEASE   
Hardware: Any   
OS: Any   

Description Peter freebsd_committer freebsd_triage 2001-08-28 16:50:00 UTC
I was running netscape v4.76 and after browseing a while the machine
starts to be real slow due swapping. After getting tired of waiting I
tried to switch to text console with Ctrl+Alt+F1. But then XFree freeze.

Tried to connect to the problem machine from a laptop the ssh deamon
only responds by connecting, no ssh init strings.. nothing. The hardisc
led is flickering so I decide to reset the machine.

After rebooting the syslog shows:
  Aug 28 16:55:24 wave /kernel: swap_pager_getswapspace: failed
  Aug 28 16:55:24 wave last message repeated 14 times
  Aug 28 16:55:54 wave last message repeated 25 times

There is a similar bug report for v4.0
o [2000/07/05] kern/19714   dillon   swap_pager_getswapspace: failed

Fix: 

debug swap_pager_getswapspace?
The former version I used killed processes when it got out of swap 
rather than letting the system down. An approach might be to let the pid
that cause out of swap (if that's the case?) to be killed.
How-To-Repeat: My Guess (no tested):
  Let a program allocate all memory available when running xfree86. 
  Then try to switch into textconsole.
Comment 1 Matt Dillon freebsd_committer freebsd_triage 2001-12-28 23:43:24 UTC
State Changed
From-To: open->closed
Comment 2 Matt Dillon freebsd_committer freebsd_triage 2001-12-28 23:45:31 UTC
State Changed
From-To: closed->open

Bleh.  hold on.  I'll close it right in a moment.
Comment 3 Matt Dillon freebsd_committer freebsd_triage 2001-12-28 23:45:47 UTC
State Changed
From-To: open->closed

Yes, you don't have enough swap to handle the programs you are running. 
4.3 had a bug in the process killing code and probably was not killing 
the largest process.  We fixed that in later releases but even so it is 
possible that FreeBSD may kill the X server itself rather then the runaway 
process if you don't have enough memory+swap. 

My recommendation is to give yourself much more swap... like 256MB or more, 
and upgrade to 4.5-RELEASE when it comes out (or upgrade to the latest -stable 
if you feel adventurous).  It may also be beneficial to set a datasize 
resource limit in your .xinitrc or .xsession (depending on how you run X), 
just before you start up your window manager, so runaway programs get killed 
before the system runs out of swap.  A 128m datasize limit would be  
reasonable.  The basic problem is that you need enough swap in the first 
place before you can set 'reasonable' resource limits for programs like 
netscape.