News for hackers. Stuff that matters.
Re:If malloc fails, it's not for the obvious reason by jws on Friday November 02, 2012 @10:36PM (#4735728)
I altered the program to first allocate 64G then go through and write on each page of the allocation on my 16G machine, dropped my swap partition.

After suitable screwing around to keep gcc from optimizing away the writes, it goes a bit like this…

  jim@gvdev:~$ ./fail
  Before
  Allocated 1 GB
  Allocated 2 GB
  ...
  Allocated 64 GB
  After
  Writing in 0 GB
  Writing in 1 GB
  ...
  Writing in 15 GB
  ... rather long delay here...
  Write failed: Broken pipe
  upstairs:~ jim$    <----- bad news here, notice the machine.
  upstairs:~ jim$ slogin gvdev.XXXXX.net
  ssh: connect to host gvdev.XXXXX.net port 22: Network is unreachable
… so now I have to get back in "going out" clothes, go downstairs, and drive over to gvdev and reboot it.
Re:If malloc fails, it's not for the obvious reason by antirez on Saturday November 03, 2012 @05:18AM (#4736256)
This is a problem with virtual machines vendors such as Linode where the configured swap space is usually tiny by default... It's much better to provide more swap (At least as much as RAM size) and see the performances start to deteriorate as a sign of alarm of overcommit, instead of having random processes killed.
Re:If malloc fails, it's not for the obvious reason by viraptor on Saturday November 03, 2012 @06:37AM (#4736339)
Always good to have your sshd on auto-respawn in case OOM makes a bad choice ;) Learned this in a similar scenario.
Re:If malloc fails, it's not for the obvious reason by mileswu on Friday November 02, 2012 @11:30PM (#4735822)
Kinda OT, but out of interest, why do you use 'slogin' instead of 'ssh'? Just old habits dieing hard from 'rlogin'?
Re:If malloc fails, it's not for the obvious reason by jws on Saturday November 03, 2012 @09:24AM (#4736531)
Yes.
Re:If malloc fails, it's not for the obvious reason by xentronium on Saturday November 03, 2012 @03:45AM (#4736141)
So, when there is no memory and no swap space available, instead of crashing, it zombifies whole system? This is weird.
Re:If malloc fails, it's not for the obvious reason by keeperofdakeys on Saturday November 03, 2012 @04:18AM (#4736188)
The linux Out Of Memory killer would have activated (if not disabled). This program derives a 'score' for each program, based on a number of statistics, and kills the process with the highest score. Although it usually makes the right choice, sometimes it can kill innocent programs.
Re:If malloc fails, it's not for the obvious reason by jws on Saturday November 03, 2012 @11:52AM (#4736861)
It was worse than a dead sshd. Looks like something kernel-ish died badly. There was one more cron message in the syslog after this, but then nothing until I rebooted. Console unresponsive, no ping answering.

  Nov  2 21:29:33 gvdev kernel: [15115318.546376] fail[17150]: 
      segfault at 7fffe9cbc1e0 ip 00000000004006fe sp 00007fffe9cbb1d0 
      error 4 in fail[400000+1000]