Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@chromium.org>2015-06-13 01:23:47 +0300
committerAdam Langley <agl@google.com>2015-06-16 21:25:30 +0300
commit184494dfccbf854212a82e230465b98ea1e86afe (patch)
treea77416ad44b4bf81248ab6da9b0382fbc8b6a25b /crypto/test
parent7c803a65d5c52e56b4eca30ec48ad52b90e0e36c (diff)
Raise SIGTRAP rather than abort on failure.
If gdb is attached, it's convenient to be able to continue running. Change-Id: I3bbb2634d05a08f6bad5425f71da2210dbb80cfe Reviewed-on: https://boringssl-review.googlesource.com/5125 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/test')
-rw-r--r--crypto/test/malloc.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/crypto/test/malloc.cc b/crypto/test/malloc.cc
index 31da2c78..898f2a7c 100644
--- a/crypto/test/malloc.cc
+++ b/crypto/test/malloc.cc
@@ -35,6 +35,7 @@
!defined(OPENSSL_AARCH64) && !defined(OPENSSL_ASAN)
#include <errno.h>
+#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -46,14 +47,14 @@
/* This file defines overrides for the standard allocation functions that allow
* a given allocation to be made to fail for testing. If the program is run
* with MALLOC_NUMBER_TO_FAIL set to a base-10 number then that allocation will
- * return NULL. If MALLOC_ABORT_ON_FAIL is also defined then the allocation
- * will abort() rather than return NULL.
+ * return NULL. If MALLOC_BREAK_ON_FAIL is also defined then the allocation
+ * will signal SIGTRAP rather than return NULL.
*
* This code is not thread safe. */
static uint64_t current_malloc_count = 0;
static uint64_t malloc_number_to_fail = 0;
-static char failure_enabled = 0, abort_on_fail = 0;
+static char failure_enabled = 0, break_on_fail = 0;
static int in_call = 0;
extern "C" {
@@ -96,7 +97,7 @@ static int should_fail_allocation() {
std::set_new_handler(cpp_new_handler);
}
}
- abort_on_fail = (NULL != getenv("MALLOC_ABORT_ON_FAIL"));
+ break_on_fail = (NULL != getenv("MALLOC_BREAK_ON_FAIL"));
init = 1;
}
@@ -109,8 +110,8 @@ static int should_fail_allocation() {
should_fail = (current_malloc_count == malloc_number_to_fail);
current_malloc_count++;
- if (should_fail && abort_on_fail) {
- abort();
+ if (should_fail && break_on_fail) {
+ raise(SIGTRAP);
}
return should_fail;
}