UMEM_SETMTBF(3MALLOC) Memory Allocation Library Functions UMEM_SETMTBF(3MALLOC)

umem_setmtbf
set umem failure threshold

Object-Caching Memory Allocation Library (libumem, -lumem
#include <umem.h>

void
umem_setmtbf(uint_t thresh);

The umem_setmtbf() function can be used to modify the run-time behavior of the libumem(3LIB) library to set a threshold to cause injected memory allocation failures.

By default, no failures are injected. When a non-zero value is passed in thresh then error injection is enabled, if the umem debugging features described in umem_debug(3MALLOC) are enabled through the UMEM_DEBUG environment variable. If a process has not enabled the debugging functionality of libumem(3LIB) then no errors will be injected, no matter what thresh is set to.

Passing the value 0 disables error injection. To cause every allocation to fail, pass the value 1. The larger the value passed, the more time that will pass between error injections. Currently, an error is injected if the current time in nanoseconds since boot modulus the mtbf is zero. Concretely:

if (gethrtime() % thresh) == 0) {
	<inject error>
}

This mechanism is not guaranteed over time; however, the meanings of a threshold of zero, one, and the general tendency of larger numbers to indicate less errors is.

Unsafe

Uncommitted

libumem(3LIB), umem_debug(3MALLOC)
February 23, 2020 OmniOS