diff options
Diffstat (limited to 'usr/src/lib')
-rw-r--r-- | usr/src/lib/libumem/common/envvar.c | 5 | ||||
-rw-r--r-- | usr/src/lib/libumem/common/umem.c | 6 | ||||
-rw-r--r-- | usr/src/lib/libumem/common/umem_impl.h | 3 |
3 files changed, 13 insertions, 1 deletions
diff --git a/usr/src/lib/libumem/common/envvar.c b/usr/src/lib/libumem/common/envvar.c index 0c4d872814..6c57d9553e 100644 --- a/usr/src/lib/libumem/common/envvar.c +++ b/usr/src/lib/libumem/common/envvar.c @@ -26,6 +26,7 @@ /* * Copyright (c) 2012 Joyent, Inc. All rights reserved. + * Copyright (c) 2015 by Delphix. All rights reserved. */ #include <ctype.h> @@ -226,6 +227,10 @@ static umem_env_item_t umem_debug_items[] = { "Enables writing all logged messages to stderr", &umem_output, 2 }, + { "checknull", "Private", ITEM_FLAG, + "Abort if an allocation would return null", + &umem_flags, UMF_CHECKNULL + }, { NULL, "-- end of UMEM_DEBUG --", ITEM_INVALID } }; diff --git a/usr/src/lib/libumem/common/umem.c b/usr/src/lib/libumem/common/umem.c index 00028e5f80..dbc738a049 100644 --- a/usr/src/lib/libumem/common/umem.c +++ b/usr/src/lib/libumem/common/umem.c @@ -26,6 +26,7 @@ /* * Copyright (c) 2014 Joyent, Inc. All rights reserved. + * Copyright (c) 2015 by Delphix. All rights reserved. */ /* @@ -1234,6 +1235,9 @@ umem_alloc_retry(umem_cache_t *cp, int umflag) * Initialization failed. Do normal failure processing. */ } + if (umem_flags & UMF_CHECKNULL) { + umem_err_recoverable("umem: out of heap space"); + } if (umflag & UMEM_NOFAIL) { int def_result = UMEM_CALLBACK_EXIT(255); int result = def_result; @@ -1377,7 +1381,7 @@ umem_log_enter(umem_log_header_t *lhp, void *data, size_t size) static void umem_log_event(umem_log_header_t *lp, umem_cache_t *cp, - umem_slab_t *sp, void *addr) + umem_slab_t *sp, void *addr) { umem_bufctl_audit_t *bcp; UMEM_LOCAL_BUFCTL_AUDIT(&bcp); diff --git a/usr/src/lib/libumem/common/umem_impl.h b/usr/src/lib/libumem/common/umem_impl.h index f63246e166..7d5056f172 100644 --- a/usr/src/lib/libumem/common/umem_impl.h +++ b/usr/src/lib/libumem/common/umem_impl.h @@ -26,6 +26,7 @@ /* * Copyright (c) 2012 Joyent, Inc. All rights reserved. + * Copyright (c) 2015 by Delphix. All rights reserved. */ #ifndef _UMEM_IMPL_H @@ -68,6 +69,8 @@ extern "C" { #define UMF_RANDOMIZE 0x00000400 /* randomize other umem_flags */ #define UMF_PTC 0x00000800 /* cache has per-thread caching */ +#define UMF_CHECKNULL 0x00001000 /* heap exhaustion checking */ + #define UMF_BUFTAG (UMF_DEADBEEF | UMF_REDZONE) #define UMF_TOUCH (UMF_BUFTAG | UMF_LITE | UMF_CONTENTS) #define UMF_RANDOM (UMF_TOUCH | UMF_AUDIT | UMF_NOMAGAZINE) |