2 .\" Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH UMEM_DEBUG 3MALLOC "Jul 26, 2002"
8 umem_debug \- debugging features of the umem library
12 \fBcc\fR [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lumem\fR [ \fIlibrary\fR\&.\|.\|. ]
13 #include <\fBumem.h\fR>
19 The \fBlibumem\fR library provides debugging features that detect memory leaks,
20 buffer overruns, multiple frees, use of uninitialized data, use of freed data,
21 and many other common programming errors. The activation of the run-time
22 debugging features is controlled by environment variables.
25 When the library detects an error, it writes a description of the error to an
26 internal buffer that is readable with the \fB::umem_status\fR \fBmdb\fR(1)
27 \fIdcmd\fR and then calls \fBabort\fR(3C).
28 .SH ENVIRONMENT VARIABLES
32 \fB\fBUMEM_DEBUG\fR\fR
35 This variable contains a list of comma-separated options. Unrecognized options
36 are ignored. Possible options include:
40 \fB\fBaudit\fR[=\fIframes\fR]\fR
43 This option enables the recording of auditing information, including thread ID,
44 high-resolution time stamp, and stack trace for the last action (allocation or
45 free) on every allocation. If transaction logging (see \fBUMEM_LOGGING\fR) is
46 enabled, this auditing information is also logged.
48 The \fIframes\fR parameter sets the number of stack frames recorded in the
49 auditing structure. The upper bound for frames is implementation-defined. If a
50 larger value is requested, the upper bound is used instead.
52 If \fIframes\fR is not specified or is not an integer, the default value of 15
55 This option also enables the \fBguards\fR option.
61 \fB\fBcontents\fR[=\fIcount\fR]\fR
64 If auditing and contents logging (see \fBUMEM_LOGGING\fR) are enabled, the
65 first \fIcount\fR bytes of each buffer are logged when they are freed. If a
66 buffer is shorter than \fIcount\fR bytes, it is logged in its entirety.
68 If \fIcount\fR is not specified or is not an integer, the default value of 256
78 This option is equivalent to \fBaudit\fR,\fBcontents\fR,\fBguards\fR.
87 This option enables filling allocated and freed buffers with special patterns
88 to help detect the use of uninitialized data and previously freed buffers. It
89 also enables an 8-byte redzone after each buffer that contains
90 \fB0xfeedfacefeedfaceULL\fR.
92 When an object is freed, it is filled with \fB0xdeadbeef\fR. When an object is
93 allocated, the \fB0xdeadbeef\fR pattern is verified and replaced with
94 \fB0xbaddcafe\fR. The redzone is checked every time a buffer is allocated or
97 For caches with either constructors or destructors, or both,
98 \fBumem_cache_alloc\fR(3MALLOC) and \fBumem_cache_free\fR(3MALLOC) apply the
99 cache's constructor and destructor, respectively, instead of caching
100 constructed objects. The presence of \fBassert\fR(3C)s in the destructor
101 verifying that the buffer is in the constructed state can be used to detect any
102 objects returned in an improper state. See \fBumem_cache_create\fR(3MALLOC)
112 The library writes error descriptions to standard error before aborting. These
113 messages are not localized.
121 \fB\fBUMEM_LOGGING\fR\fR
124 To be enabled, this variable should be set to a comma-separated list of
125 in-memory logs. The logs available are:
129 \fB\fBtransaction\fR[=\fIsize\fR]\fR
132 If the \fBaudit\fR debugging option is set (see \fBUMEM_DEBUG\fR), the audit
133 structures from previous transactions are entered into this log.
139 \fB\fBcontents\fR[=\fIsize\fR]\fR
142 If the \fBaudit\fR debugging option is set, the contents of objects are
143 recorded in this log as they are freed.
145 If the "contents" debugging option was not set, 256 bytes of each freed buffer
152 \fB\fBfail\fR[=\fIsize\fR]\fR
155 Records are entered into this log for every failed allocation.
158 For any of these options, if \fIsize\fR is not specified, the default value of
159 64k is used. The \fIsize\fR parameter must be an integer that can be qualified
160 with K, M, G, or T to specify kilobytes, megabytes, gigabytes, or terabytes,
163 Logs that are not listed or that have either a size of 0 or an invalid size are
166 The log is disabled if during initialization the requested amount of storage
173 See \fBattributes\fR(5) for descriptions of the following attributes:
181 ATTRIBUTE TYPE ATTRIBUTE VALUE
183 Interface Stability Unstable
191 \fBmdb\fR(1), \fBabort\fR(3C), \fBsignal\fR(3C),
192 \fBumem_cache_create\fR(3MALLOC), \fBattributes\fR(5)
195 \fISolaris Modular Debugger Guide\fR
199 When \fBlibumem\fR aborts the process using \fBabort\fR(3C), any existing
200 signal handler for \fBSIGABRT\fR is called. If the signal handler performs
201 allocations, undefined behavior can result.
205 Some of the debugging features work only for allocations smaller than 16
206 kilobytes in size. Allocations larger than 16 kilobytes could have reduced
210 Activating any of the library's debugging features could significantly increase
211 the library's memory footprint and decrease its performance.