Browse Source

Long ago, malloc internally had two kinds of failures, warnings and errors.

The 'A' option elevated warnings to errors, and has been the default for some
time. Then warnings were effectively eliminated in favor of everything
being an error, but then the 'a' flag turned real errors into warnings!
Remove the 'a' option entirely. You shouldn't have used it anyway.
ok tb tdeval
OPENBSD_5_9
tedu 9 years ago
parent
commit
c3dcc81b75
2 changed files with 7 additions and 14 deletions
  1. +3
    -6
      src/lib/libc/stdlib/malloc.3
  2. +4
    -8
      src/lib/libc/stdlib/malloc.c

+ 3
- 6
src/lib/libc/stdlib/malloc.3 View File

@ -30,9 +30,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: malloc.3,v 1.91 2015/09/14 13:08:01 schwarze Exp $
.\" $OpenBSD: malloc.3,v 1.92 2016/01/06 17:57:22 tedu Exp $
.\" .\"
.Dd $Mdocdate: September 14 2015 $
.Dd $Mdocdate: January 6 2016 $
.Dt MALLOC 3 .Dt MALLOC 3
.Os .Os
.Sh NAME .Sh NAME
@ -345,10 +345,7 @@ or
detect an error condition, detect an error condition,
a message will be printed to file descriptor a message will be printed to file descriptor
2 (not using stdio). 2 (not using stdio).
Errors will result in the process being aborted,
unless the
.Cm a
option has been specified.
Errors will result in the process being aborted.
.Pp .Pp
Here is a brief description of the error messages and what they mean: Here is a brief description of the error messages and what they mean:
.Bl -tag -width Ds .Bl -tag -width Ds


+ 4
- 8
src/lib/libc/stdlib/malloc.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: malloc.c,v 1.179 2015/12/30 06:04:39 tedu Exp $ */
/* $OpenBSD: malloc.c,v 1.180 2016/01/06 17:57:22 tedu Exp $ */
/* /*
* Copyright (c) 2008, 2010, 2011 Otto Moerbeek <otto@drijf.net> * Copyright (c) 2008, 2010, 2011 Otto Moerbeek <otto@drijf.net>
* Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
@ -177,7 +177,6 @@ struct chunk_info {
struct malloc_readonly { struct malloc_readonly {
struct dir_info *malloc_pool; /* Main bookkeeping information */ struct dir_info *malloc_pool; /* Main bookkeeping information */
int malloc_abort; /* abort() on error */
int malloc_freenow; /* Free quickly - disable chunk rnd */ int malloc_freenow; /* Free quickly - disable chunk rnd */
int malloc_freeunmap; /* mprotect free pages PROT_NONE? */ int malloc_freeunmap; /* mprotect free pages PROT_NONE? */
int malloc_hint; /* call madvice on free pages? */ int malloc_hint; /* call madvice on free pages? */
@ -280,8 +279,8 @@ wrterror(char *msg, void *p)
#endif /* MALLOC_STATS */ #endif /* MALLOC_STATS */
errno = saved_errno; errno = saved_errno;
if (mopts.malloc_abort)
abort();
abort();
} }
static void static void
@ -485,7 +484,6 @@ omalloc_init(struct dir_info **dp)
/* /*
* Default options * Default options
*/ */
mopts.malloc_abort = 1;
mopts.malloc_junk = 1; mopts.malloc_junk = 1;
mopts.malloc_move = 1; mopts.malloc_move = 1;
mopts.malloc_cache = MALLOC_DEFAULT_CACHE; mopts.malloc_cache = MALLOC_DEFAULT_CACHE;
@ -523,10 +521,8 @@ omalloc_init(struct dir_info **dp)
mopts.malloc_cache >>= 1; mopts.malloc_cache >>= 1;
break; break;
case 'a': case 'a':
mopts.malloc_abort = 0;
break;
case 'A': case 'A':
mopts.malloc_abort = 1;
/* ignored */
break; break;
case 'c': case 'c':
mopts.malloc_canaries = 0; mopts.malloc_canaries = 0;


Loading…
Cancel
Save