In message <> Mikhail Teterin writes:
: Then, one can write a safe malloc, which will install the signal
: handler, and touch every page in the the memory referenced by the
: to-be-returned pointer. If the signal handler is invoked in the
: progress, the to-be-returned memory must be returned back to the
: system and NULL should be returned to the caller.

This won't work all the time.  FreeBSD overcommits swap space and you
may get a SIGKILL even if you've touched all the pages.  FreeBSD kills
processes when swap space runs out.

: However, my (in)ability to propose anything remotely sensible does
: not change the facts established in this painful thread. That our
: malloc does not conform to standards (for whatever reasons), and
: that something should be done about it. That "something" must start
: with documenting the flaw...

The behavior is documented:
     The malloc() and calloc() functions return a pointer to the allocated
     memory if successful; otherwise a NULL pointer is returned.

What the system does when it has resource shortages is beyond the
scope of the ANSI-C standard, so I don't see why you say that
FreeBSD's malloc isn't standard conforming.


To Unsubscribe: send mail to
with "unsubscribe freebsd-current" in the body of the message

Reply via email to