1umem_debug(3MALLOC) Memory Allocation Library Functions umem_debug(3MALLOC)
2
3
4
6 umem_debug - debugging features of the umem library
7
9 cc [ flag... ] file... -lumem [ library... ]
10 #include <umem.h>
11
12
14 The libumem library provides debugging features that detect memory
15 leaks, buffer overruns, multiple frees, use of uninitialized data, use
16 of freed data, and many other common programming errors. The activation
17 of the run-time debugging features is controlled by environment vari‐
18 ables.
19
20
21 When the library detects an error, it writes a description of the error
22 to an internal buffer that is readable with the ::umem_status mdb(1)
23 dcmd and then calls abort(3C).
24
26 UMEM_DEBUG This variable contains a list of comma-separated
27 options. Unrecognized options are ignored. Possible
28 options include:
29
30 audit[=frames] This option enables the recording
31 of auditing information, including
32 thread ID, high-resolution time
33 stamp, and stack trace for the last
34 action (allocation or free) on
35 every allocation. If transaction
36 logging (see UMEM_LOGGING) is
37 enabled, this auditing information
38 is also logged.
39
40 The frames parameter sets the num‐
41 ber of stack frames recorded in the
42 auditing structure. The upper bound
43 for frames is implementation-
44 defined. If a larger value is
45 requested, the upper bound is used
46 instead.
47
48 If frames is not specified or is
49 not an integer, the default value
50 of 15 is used.
51
52 This option also enables the guards
53 option.
54
55
56 contents[=count] If auditing and contents logging
57 (see UMEM_LOGGING) are enabled, the
58 first count bytes of each buffer
59 are logged when they are freed. If
60 a buffer is shorter than count
61 bytes, it is logged in its
62 entirety.
63
64 If count is not specified or is not
65 an integer, the default value of
66 256 is used.
67
68
69 default This option is equivalent to
70 audit,contents,guards.
71
72
73 guards This option enables filling allo‐
74 cated and freed buffers with spe‐
75 cial patterns to help detect the
76 use of uninitialized data and pre‐
77 viously freed buffers. It also
78 enables an 8-byte redzone after
79 each buffer that contains 0xfeed‐
80 facefeedfaceULL.
81
82 When an object is freed, it is
83 filled with 0xdeadbeef. When an
84 object is allocated, the 0xdeadbeef
85 pattern is verified and replaced
86 with 0xbaddcafe. The redzone is
87 checked every time a buffer is
88 allocated or freed.
89
90 For caches with either constructors
91 or destructors, or both,
92 umem_cache_alloc(3MALLOC) and
93 umem_cache_free(3MALLOC) apply the
94 cache's constructor and destructor,
95 respectively, instead of caching
96 constructed objects. The presence
97 of assert(3C)s in the destructor
98 verifying that the buffer is in the
99 constructed state can be used to
100 detect any objects returned in an
101 improper state. See
102 umem_cache_create(3MALLOC) for
103 details.
104
105
106 verbose The library writes error descrip‐
107 tions to standard error before
108 aborting. These messages are not
109 localized.
110
111
112
113 UMEM_LOGGING To be enabled, this variable should be set to a comma-
114 separated list of in-memory logs. The logs available
115 are:
116
117 transaction[=size] If the audit debugging option is
118 set (see UMEM_DEBUG), the audit
119 structures from previous transac‐
120 tions are entered into this log.
121
122
123 contents[=size] If the audit debugging option is
124 set, the contents of objects are
125 recorded in this log as they are
126 freed.
127
128 If the "contents" debugging
129 option was not set, 256 bytes of
130 each freed buffer are saved.
131
132
133 fail[=size] Records are entered into this log
134 for every failed allocation.
135
136 For any of these options, if size is not specified, the
137 default value of 64k is used. The size parameter must
138 be an integer that can be qualified with K, M, G, or T
139 to specify kilobytes, megabytes, gigabytes, or ter‐
140 abytes, respectively.
141
142 Logs that are not listed or that have either a size of
143 0 or an invalid size are disabled.
144
145 The log is disabled if during initialization the
146 requested amount of storage cannot be allocated.
147
148
150 See attributes(5) for descriptions of the following attributes:
151
152
153
154
155 ┌─────────────────────────────┬─────────────────────────────┐
156 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
157 ├─────────────────────────────┼─────────────────────────────┤
158 │Interface Stability │Unstable │
159 ├─────────────────────────────┼─────────────────────────────┤
160 │MT-Level │MT-Safe │
161 └─────────────────────────────┴─────────────────────────────┘
162
164 mdb(1), abort(3C), signal(3C), umem_cache_create(3MALLOC),
165 attributes(5)
166
167
168 Solaris Modular Debugger Guide
169
171 When libumem aborts the process using abort(3C), any existing signal
172 handler for SIGABRT is called. If the signal handler performs alloca‐
173 tions, undefined behavior can result.
174
176 Some of the debugging features work only for allocations smaller than
177 16 kilobytes in size. Allocations larger than 16 kilobytes could have
178 reduced support.
179
180
181 Activating any of the library's debugging features could significantly
182 increase the library's memory footprint and decrease its performance.
183
184
185
186SunOS 5.11 26 July 2002 umem_debug(3MALLOC)