diff options
author | otto <> | 2023-06-23 05:26:45 +0000 |
---|---|---|
committer | otto <> | 2023-06-23 05:26:45 +0000 |
commit | aad6e1a18af8150d74818331e380be1b90c153e8 (patch) | |
tree | 56ead604ef7d9f8637e7728e2881f064687aa4d5 | |
parent | 7b5ff0a69f1d3054648da799ac4ffdc9809f9526 (diff) | |
download | openbsd-aad6e1a18af8150d74818331e380be1b90c153e8.tar.gz openbsd-aad6e1a18af8150d74818331e380be1b90c153e8.tar.bz2 openbsd-aad6e1a18af8150d74818331e380be1b90c153e8.zip |
Revert previous, not all platforms allow compiling
__builtin_return_address(a) with a != 0.
-rw-r--r-- | src/lib/libc/stdlib/malloc.3 | 26 | ||||
-rw-r--r-- | src/lib/libc/stdlib/malloc.c | 15 |
2 files changed, 4 insertions, 37 deletions
diff --git a/src/lib/libc/stdlib/malloc.3 b/src/lib/libc/stdlib/malloc.3 index 855f217c27..79e85f39ee 100644 --- a/src/lib/libc/stdlib/malloc.3 +++ b/src/lib/libc/stdlib/malloc.3 | |||
@@ -30,9 +30,9 @@ | |||
30 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 30 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
31 | .\" SUCH DAMAGE. | 31 | .\" SUCH DAMAGE. |
32 | .\" | 32 | .\" |
33 | .\" $OpenBSD: malloc.3,v 1.134 2023/06/22 11:04:16 otto Exp $ | 33 | .\" $OpenBSD: malloc.3,v 1.135 2023/06/23 05:26:45 otto Exp $ |
34 | .\" | 34 | .\" |
35 | .Dd $Mdocdate: June 22 2023 $ | 35 | .Dd $Mdocdate: June 23 2023 $ |
36 | .Dt MALLOC 3 | 36 | .Dt MALLOC 3 |
37 | .Os | 37 | .Os |
38 | .Sh NAME | 38 | .Sh NAME |
@@ -294,17 +294,6 @@ To record the dump: | |||
294 | To view the leak report: | 294 | To view the leak report: |
295 | .Pp | 295 | .Pp |
296 | .Dl $ kdump -u malloc ... | 296 | .Dl $ kdump -u malloc ... |
297 | .Pp | ||
298 | By default, the immediate caller of a | ||
299 | .Nm | ||
300 | function will be recorded. | ||
301 | Use malloc options | ||
302 | .Cm 2 | ||
303 | or | ||
304 | .Cm 3 | ||
305 | to record the caller one or two stack frames deeper instead. | ||
306 | These malloc options imply | ||
307 | .Cm D . | ||
308 | .It Cm F | 297 | .It Cm F |
309 | .Dq Freecheck . | 298 | .Dq Freecheck . |
310 | Enable more extensive double free and use after free detection. | 299 | Enable more extensive double free and use after free detection. |
@@ -824,14 +813,3 @@ and | |||
824 | .Fn realloc | 813 | .Fn realloc |
825 | to avoid these problems on | 814 | to avoid these problems on |
826 | .Ox . | 815 | .Ox . |
827 | .Pp | ||
828 | The mechanism to record caller functions when using malloc options | ||
829 | .Cm 2 | ||
830 | or | ||
831 | .Cm 3 | ||
832 | is not guaranteed to work for all platforms, compilers or compilation | ||
833 | options, | ||
834 | and might even crash your program. | ||
835 | Use | ||
836 | .Em only | ||
837 | for debugging purposes. | ||
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index 7bc660525b..34b2bb5e66 100644 --- a/src/lib/libc/stdlib/malloc.c +++ b/src/lib/libc/stdlib/malloc.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: malloc.c,v 1.287 2023/06/22 11:04:16 otto Exp $ */ | 1 | /* $OpenBSD: malloc.c,v 1.288 2023/06/23 05:26:45 otto Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2008, 2010, 2011, 2016, 2023 Otto Moerbeek <otto@drijf.net> | 3 | * Copyright (c) 2008, 2010, 2011, 2016, 2023 Otto Moerbeek <otto@drijf.net> |
4 | * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> | 4 | * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> |
@@ -255,11 +255,7 @@ void malloc_dump(void); | |||
255 | PROTO_NORMAL(malloc_dump); | 255 | PROTO_NORMAL(malloc_dump); |
256 | static void malloc_exit(void); | 256 | static void malloc_exit(void); |
257 | #endif | 257 | #endif |
258 | #define CALLER ( \ | 258 | #define CALLER (DO_STATS ? __builtin_return_address(0) : NULL) |
259 | DO_STATS == 0 ? NULL : (__builtin_extract_return_addr( \ | ||
260 | DO_STATS == 1 ? __builtin_return_address(0) : \ | ||
261 | DO_STATS == 2 ? __builtin_return_address(1) : \ | ||
262 | DO_STATS == 3 ? __builtin_return_address(2) : NULL))) | ||
263 | 259 | ||
264 | /* low bits of r->p determine size: 0 means >= page size and r->size holding | 260 | /* low bits of r->p determine size: 0 means >= page size and r->size holding |
265 | * real size, otherwise low bits is the bucket + 1 | 261 | * real size, otherwise low bits is the bucket + 1 |
@@ -369,15 +365,8 @@ omalloc_parseopt(char opt) | |||
369 | mopts.malloc_stats = 0; | 365 | mopts.malloc_stats = 0; |
370 | break; | 366 | break; |
371 | case 'D': | 367 | case 'D': |
372 | case '1': | ||
373 | mopts.malloc_stats = 1; | 368 | mopts.malloc_stats = 1; |
374 | break; | 369 | break; |
375 | case '2': | ||
376 | mopts.malloc_stats = 2; | ||
377 | break; | ||
378 | case '3': | ||
379 | mopts.malloc_stats = 3; | ||
380 | break; | ||
381 | #endif /* MALLOC_STATS */ | 370 | #endif /* MALLOC_STATS */ |
382 | case 'f': | 371 | case 'f': |
383 | mopts.malloc_freecheck = 0; | 372 | mopts.malloc_freecheck = 0; |