aboutsummaryrefslogtreecommitdiffstats
path: root/vespamalloc/src/tests/stacktrace/stacktrace.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'vespamalloc/src/tests/stacktrace/stacktrace.cpp')
-rw-r--r--vespamalloc/src/tests/stacktrace/stacktrace.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/vespamalloc/src/tests/stacktrace/stacktrace.cpp b/vespamalloc/src/tests/stacktrace/stacktrace.cpp
new file mode 100644
index 00000000000..0fb0c9759a2
--- /dev/null
+++ b/vespamalloc/src/tests/stacktrace/stacktrace.cpp
@@ -0,0 +1,35 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include <stdlib.h>
+#include <stdio.h>
+#include <pthread.h>
+
+void * run(void * arg)
+{
+ (void) arg;
+ char * a = new char [100]; // a should not remain in stacktrace
+ char * b = new char [1]; // but b should as it not deleted.
+ (void) b;
+ delete [] a;
+ return NULL;
+}
+
+int main(int argc, char *argv[])
+{
+ (void) argc;
+ (void) argv;
+ char * a = new char [100]; // a should not remain in stacktrace
+ char * b = new char [1]; // but b should as it not deleted.
+ (void) b;
+ delete [] a;
+ pthread_t tid;
+ int retval = pthread_create(&tid, NULL, run, NULL);
+ if (retval != 0) {
+ perror("pthread_create failed");
+ abort();
+ }
+ retval = pthread_join(tid, NULL);
+ if (retval != 0) {
+ perror("pthread_join failed");
+ abort();
+ }
+}