bugReportStart:: fails to build on missing IFDEF HAVE_BACKTRACE #216

Closed
rbucker opened this Issue Nov 28, 2011 · 6 comments

5 participants

@rbucker

bugReportStart() is created in redis.c, however, there is a IFDEF for conditional compilation. That same condition is omitted in the two instances where it is used in debug.c.

In these two functions:

_redisAssert()
_redisPanic()

@procyber

I have the same problem on freebsd

@bnoordhuis

Same on SunOS.

@bnoordhuis

Actually, the fix for SunOS is trivial - just add || defined(__sun). The relevant bits in uc_mcontext are identical to linux.

diff --git a/src/config.h b/src/config.h
index f38ce87..323a3dd 100644
--- a/src/config.h
+++ b/src/config.h
@@ -25,7 +25,7 @@
 #endif

 /* Test for backtrace() */
-#if defined(__APPLE__) || defined(__linux__)
+#if defined(__APPLE__) || defined(__linux__) || defined(__sun)
 #define HAVE_BACKTRACE 1
 #endif
@rbucker
@zaa
zaa commented Dec 7, 2011

Confirm. The fact that HAVE_BACKTRACE is not defined on FreeBSD causes redis-2.4.4 build to fail.

cc -o redis-server -std=c99 -pedantic -O2 -Wall -W     -g -rdynamic -ggdb adlist.o ae.o anet.o dict.o redis.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o vm.o pubsub.o multi.o debug.o sort.o intset.o syncio.o slowlog.o bio.o -lm -pthread 
debug.o(.text+0x7): In function `_redisPanic':
/home/zaa1/redis-2.4.4/src/debug.c:353: undefined reference to `bugReportStart'
debug.o(.text+0x57): In function `_redisAssert':
/home/zaa1/redis-2.4.4/src/debug.c:340: undefined reference to `bugReportStart'

A possible fix is to move the bugReportStart function off of the block protected with HAVE_BACKTRACE. For example, like this:

zaa1 ~/redis-2.4.4/src> diff -ub redis.c.orig redis.c
--- redis.c.orig    2011-12-07 15:58:54.000000000 +0400
+++ redis.c 2011-12-07 15:59:39.000000000 +0400
@@ -1713,14 +1713,6 @@
 #endif
 }

-void bugReportStart(void) {
-    if (server.bug_report_start == 0) {
-        redisLog(REDIS_WARNING,
-            "=== REDIS BUG REPORT START: Cut & paste starting from here ===");
-        server.bug_report_start = 1;
-    }
-}
-
 static void sigsegvHandler(int sig, siginfo_t *info, void *secret) {
     void *trace[100];
     char **messages = NULL;
@@ -1807,4 +1799,13 @@
     return;
 }

+void bugReportStart(void) {
+    if (server.bug_report_start == 0) {
+        redisLog(REDIS_WARNING,
+            "=== REDIS BUG REPORT START: Cut & paste starting from here ===");
+        server.bug_report_start = 1;
+    }
+}
+
+
 /* The End */
@zaa
zaa commented Dec 8, 2011

I've created a pull request #240

@mattsta mattsta closed this Aug 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment