bug: undefined reference to `cache_error' when running make after CFLAGS='-DNDEBUG' ./configure

56 views
Skip to first unread message

張俊芝

unread,
Jun 24, 2021, 2:57:11 AM6/24/21
to memcached

Version: 1.6.9

Steps to reproduce the bug:

  Run the following commands:
    CFLAGS='-DNDEBUG' ./configure
    make

  When compiling testapp.c, the error of undefined reference to `cache_error' would happen.

Path that fixes the bug:
@@ -1,5 +1,8 @@
 /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+#ifdef NDEBUG
 #undef NDEBUG
+#define PRODUCT_BUILT_WITH_NDEBUG
+#endif
 #include <pthread.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -236,12 +239,16 @@
     char old = *(p - 1);
     *(p - 1) = 0;
     cache_free(cache, p);
+    #ifndef PRODUCT_BUILT_WITH_NDEBUG
     assert(cache_error == -1);
+    #endif
     *(p - 1) = old;
 
     p[sizeof(uint32_t)] = 0;
     cache_free(cache, p);
+    #ifndef PRODUCT_BUILT_WITH_NDEBUG
     assert(cache_error == 1);
+    #endif
 
     /* restore signal handler */
     sigaction(SIGABRT, &old_action, NULL);

dormando

unread,
Jun 29, 2021, 4:30:47 PM6/29/21
to memcached
Hey,

I'm not going to fix this one I think; testapp needs to be built without
NDEBUG. You shouldn't be passing that flag in; the build system makes the
main memcached binary with NDEBUG already.
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "memcached" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to memcached+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/memcached/cd5e8bd8-af2d-429a-af97-1e66a964ee91n%40googlegroups.com.
>
>
Reply all
Reply to author
Forward
0 new messages