__uc_malloc hooks

Rob Landley rob at landley.net
Mon Sep 17 04:03:39 UTC 2007


On Saturday 15 September 2007 3:19:33 am Mike Frysinger wrote:
> more to the point ... how exactly would __uc_malloc be useful ?  i dont
> think ive ever seen malloc() return NULL as the kernel is the first to find
> out about the OOM situation and properly nukes any userspace app before it
> ever sees the relevant NULL ...
> -mike

Generally malloc() returns NULL when you've exhausted virtual memory (not 
physical memory, which you find out about after the fact by the OOM killer 
shooting you in the head when you dirty enough pages).  Not much of a concern 
on 64 bit platforms, but on 32 bit you can trivially run into this if you've 
done a couple of large mmap() calls...

That said, testing for NULL is seldom useful because attempts to use the 
result give you a nice null pointer dereference and a segfault, cleanly 
ending the program anyway.

Rob
-- 
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.



More information about the uClibc mailing list