summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2018-06-21 20:00:41 +1000
committerKarolin Seeger <kseeger@samba.org>2018-07-10 10:44:13 +0200
commita19d52e6c827b78d3883d37fcdaa76013e5c3177 (patch)
tree0a15d29c4caa6751116f21c3d6f441217d8d016f /ctdb
parent6600f4b1641160c902e8318c64a33575610deb31 (diff)
downloadsamba-a19d52e6c827b78d3883d37fcdaa76013e5c3177.tar.gz
ctdb-tests: Avoid segfault by initializing logging
Setting DEBUGLEVEL before calling debug_init() causes segmentation violation with gcc8. DEBUGLEVEL_CLASS is statically initialized to debug_class_list_initial which is defined as const. Only after debug_init() is called, DEBUGLEVEL_CLASS becomes a talloc'd array. So before modifying DEBUGLEVEL, ensure debug_init() is called via setup_logging(). (debug_init is a static function.) Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net> (cherry picked from commit af697008531bd74546656841dd3a1ed92522fc57)
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/tests/src/fetch_loop.c3
-rw-r--r--ctdb/tests/src/fetch_loop_key.c3
-rw-r--r--ctdb/tests/src/fetch_readonly.c3
-rw-r--r--ctdb/tests/src/fetch_readonly_loop.c3
-rw-r--r--ctdb/tests/src/fetch_ring.c3
-rw-r--r--ctdb/tests/src/g_lock_loop.c4
-rw-r--r--ctdb/tests/src/message_ring.c3
-rw-r--r--ctdb/tests/src/transaction_loop.c3
-rw-r--r--ctdb/tests/src/tunnel_test.c3
-rw-r--r--ctdb/tests/src/update_record.c3
-rw-r--r--ctdb/tests/src/update_record_persistent.c3
-rw-r--r--ctdb/wscript2
12 files changed, 33 insertions, 3 deletions
diff --git a/ctdb/tests/src/fetch_loop.c b/ctdb/tests/src/fetch_loop.c
index 6767f71207a..0e1d9dadfba 100644
--- a/ctdb/tests/src/fetch_loop.c
+++ b/ctdb/tests/src/fetch_loop.c
@@ -20,6 +20,7 @@
#include "replace.h"
#include "system/network.h"
+#include "lib/util/debug.h"
#include "lib/util/tevent_unix.h"
#include "client/client.h"
@@ -230,6 +231,8 @@ int main(int argc, const char *argv[])
int ret;
bool status;
+ setup_logging("fetch_loop", DEBUG_STDERR);
+
status = process_options_basic(argc, argv, &opts);
if (! status) {
exit(1);
diff --git a/ctdb/tests/src/fetch_loop_key.c b/ctdb/tests/src/fetch_loop_key.c
index b13784224f5..3f41ca75954 100644
--- a/ctdb/tests/src/fetch_loop_key.c
+++ b/ctdb/tests/src/fetch_loop_key.c
@@ -20,6 +20,7 @@
#include "replace.h"
#include "system/network.h"
+#include "lib/util/debug.h"
#include "lib/util/tevent_unix.h"
#include "client/client.h"
@@ -155,6 +156,8 @@ int main(int argc, const char *argv[])
int ret;
bool status;
+ setup_logging("fetch_loop_key", DEBUG_STDERR);
+
status = process_options_database(argc, argv, &opts);
if (! status) {
exit(1);
diff --git a/ctdb/tests/src/fetch_readonly.c b/ctdb/tests/src/fetch_readonly.c
index 5d2972a3f09..ff126bdf5ae 100644
--- a/ctdb/tests/src/fetch_readonly.c
+++ b/ctdb/tests/src/fetch_readonly.c
@@ -20,6 +20,7 @@
#include "replace.h"
#include "system/network.h"
+#include "lib/util/debug.h"
#include "lib/util/tevent_unix.h"
#include "client/client.h"
@@ -107,6 +108,8 @@ int main(int argc, const char *argv[])
int ret;
bool status;
+ setup_logging("fetch_readonly", DEBUG_STDERR);
+
status = process_options_database(argc, argv, &opts);
if (! status) {
exit(1);
diff --git a/ctdb/tests/src/fetch_readonly_loop.c b/ctdb/tests/src/fetch_readonly_loop.c
index 9d5d22e7534..08cf4766659 100644
--- a/ctdb/tests/src/fetch_readonly_loop.c
+++ b/ctdb/tests/src/fetch_readonly_loop.c
@@ -20,6 +20,7 @@
#include "replace.h"
#include "system/network.h"
+#include "lib/util/debug.h"
#include "lib/util/tevent_unix.h"
#include "client/client.h"
@@ -214,6 +215,8 @@ int main(int argc, const char *argv[])
int ret;
bool status;
+ setup_logging("fetch_readonly_loop", DEBUG_STDERR);
+
status = process_options_basic(argc, argv, &opts);
if (! status) {
exit(1);
diff --git a/ctdb/tests/src/fetch_ring.c b/ctdb/tests/src/fetch_ring.c
index eb64648139e..f746e789511 100644
--- a/ctdb/tests/src/fetch_ring.c
+++ b/ctdb/tests/src/fetch_ring.c
@@ -20,6 +20,7 @@
#include "replace.h"
#include "system/network.h"
+#include "lib/util/debug.h"
#include "lib/util/time.h"
#include "lib/util/tevent_unix.h"
@@ -331,6 +332,8 @@ int main(int argc, const char *argv[])
int ret;
bool status;
+ setup_logging("fetch_ring", DEBUG_STDERR);
+
status = process_options_basic(argc, argv, &opts);
if (! status) {
exit(1);
diff --git a/ctdb/tests/src/g_lock_loop.c b/ctdb/tests/src/g_lock_loop.c
index f29d0f1235a..3b84241ff20 100644
--- a/ctdb/tests/src/g_lock_loop.c
+++ b/ctdb/tests/src/g_lock_loop.c
@@ -213,6 +213,8 @@ int main(int argc, const char *argv[])
int ret;
bool status;
+ setup_logging("glock_loop", DEBUG_STDERR);
+
status = process_options_basic(argc, argv, &opts);
if (! status) {
exit(1);
@@ -230,8 +232,6 @@ int main(int argc, const char *argv[])
exit(1);
}
- setup_logging("glock_loop", DEBUG_STDERR);
-
ret = ctdb_client_init(mem_ctx, ev, opts->socket, &client);
if (ret != 0) {
fprintf(stderr, "Failed to initialize client, ret=%d\n", ret);
diff --git a/ctdb/tests/src/message_ring.c b/ctdb/tests/src/message_ring.c
index dabae65ff86..d1fcee4e358 100644
--- a/ctdb/tests/src/message_ring.c
+++ b/ctdb/tests/src/message_ring.c
@@ -20,6 +20,7 @@
#include "replace.h"
#include "system/network.h"
+#include "lib/util/debug.h"
#include "lib/util/time.h"
#include "lib/util/tevent_unix.h"
@@ -317,6 +318,8 @@ int main(int argc, const char *argv[])
int ret;
bool status;
+ setup_logging("message_ring", DEBUG_STDERR);
+
status = process_options_basic(argc, argv, &opts);
if (! status) {
exit(1);
diff --git a/ctdb/tests/src/transaction_loop.c b/ctdb/tests/src/transaction_loop.c
index 66237512c87..a423d6817fd 100644
--- a/ctdb/tests/src/transaction_loop.c
+++ b/ctdb/tests/src/transaction_loop.c
@@ -20,6 +20,7 @@
#include "replace.h"
#include "system/network.h"
+#include "lib/util/debug.h"
#include "lib/util/tevent_unix.h"
#include "client/client.h"
@@ -342,6 +343,8 @@ int main(int argc, const char *argv[])
int ret;
bool status;
+ setup_logging("transaction_loop", DEBUG_STDERR);
+
status = process_options_database(argc, argv, &opts);
if (! status) {
exit(1);
diff --git a/ctdb/tests/src/tunnel_test.c b/ctdb/tests/src/tunnel_test.c
index 53ad83057ed..a6d44ba19c3 100644
--- a/ctdb/tests/src/tunnel_test.c
+++ b/ctdb/tests/src/tunnel_test.c
@@ -20,6 +20,7 @@
#include "replace.h"
#include "system/network.h"
+#include "lib/util/debug.h"
#include "lib/util/tevent_unix.h"
#include "protocol/protocol_private.h"
@@ -429,6 +430,8 @@ int main(int argc, const char *argv[])
int ret;
bool status;
+ setup_logging("tunnel_test", DEBUG_STDERR);
+
status = process_options_basic(argc, argv, &opts);
if (! status) {
exit(1);
diff --git a/ctdb/tests/src/update_record.c b/ctdb/tests/src/update_record.c
index 78291d7dc8e..11b6050ad81 100644
--- a/ctdb/tests/src/update_record.c
+++ b/ctdb/tests/src/update_record.c
@@ -20,6 +20,7 @@
#include "replace.h"
#include "system/network.h"
+#include "lib/util/debug.h"
#include "lib/util/tevent_unix.h"
#include "protocol/protocol_api.h"
@@ -177,6 +178,8 @@ int main(int argc, const char *argv[])
int ret;
bool status;
+ setup_logging("update_record", DEBUG_STDERR);
+
status = process_options_database(argc, argv, &opts);
if (! status) {
exit(1);
diff --git a/ctdb/tests/src/update_record_persistent.c b/ctdb/tests/src/update_record_persistent.c
index 9323e3743c2..2d6d21e25cf 100644
--- a/ctdb/tests/src/update_record_persistent.c
+++ b/ctdb/tests/src/update_record_persistent.c
@@ -20,6 +20,7 @@
#include "replace.h"
#include "system/network.h"
+#include "lib/util/debug.h"
#include "lib/util/tevent_unix.h"
#include "protocol/protocol_api.h"
@@ -153,6 +154,8 @@ int main(int argc, const char *argv[])
int ret;
bool status;
+ setup_logging("update_record_persistene", DEBUG_STDERR);
+
status = process_options_database(argc, argv, &opts);
if (! status) {
exit(1);
diff --git a/ctdb/wscript b/ctdb/wscript
index 6a039991a8f..1ca90a4d5b0 100644
--- a/ctdb/wscript
+++ b/ctdb/wscript
@@ -816,7 +816,7 @@ def build(bld):
source=bld.SUBDIR('tests/src',
'cluster_wait.c test_options.c'),
includes='include',
- deps='replace popt talloc tevent tdb')
+ deps='samba-util replace popt talloc tevent tdb')
# Test binaries
ctdb_tests = [