Skip to content

[Bug]: undefined reference to `absl::lts_20240116::raw_log_internal::internal_log_function[abi:cxx11]' #1674

@dfarley1

Description

@dfarley1

Describe the issue

I'm attempting to integrate a btree_multiset into our project. So far I haven't needed to build or link the abseil project itself, the btree types seem to be header-only for the most part (yay!).

However, once I got to testing I turned on ASan and ran into this compilation error:

/usr/bin/x86_64-pc-linux-gnu-ld.bfd: obj/blockmap_btree.o: in function `void absl::lts_20240116::container_internal::btree_iterator_generation_info_enabled::assert_valid_generation<absl::lts_20240116::container_internal::btree_node<absl::lts_20240116::container_internal::set_params<blockmap_btree_entry, std::less<blockmap_btree_entry>, std::allocator<blockmap_btree_entry>, 256, true> > >(absl::lts_20240116::container_internal::btree_node<absl::lts_20240116::container_internal::set_params<blockmap_btree_entry, std::less<blockmap_btree_entry>, std::allocator<blockmap_btree_entry>, 256, true> > const*) const':
/depot/out/Asan/../../vendor/abseil-cpp/absl/container/internal/btree.h:1082: undefined reference to `absl::lts_20240116::raw_log_internal::internal_log_function[abi:cxx11]'
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

I don't actually see any definition of internal_log_function, so I'm guessing it's generated or templated out somewhere during the full abseil build? In any case we don't need or want the logging at all, so I was hoping to basically

#define ABSL_INTERNAL_LOG(severity, message) assert(false, message)
#include "absl/container/btree_set.h"

in our code. Unfortunately that leads to a 'ABSL_INTERNAL_LOG' macro redefined error since there's no #ifdef check first.

Since this is the only instance of logging in the btree types, I went ahead and swapped it out with an assert() that I think is more consistent with the rest of the btree code. Is there any interest in upstreaming this change and/or adding the ability to disable internal logging so that the btree containers can keep being header-only?

diff --git a/absl/container/internal/btree.h b/absl/container/internal/btree.h
index 91df57a3..d590e4a4 100644
--- a/absl/container/internal/btree.h
+++ b/absl/container/internal/btree.h
@@ -58,7 +58,6 @@
 #include <type_traits>
 #include <utility>

-#include "absl/base/internal/raw_logging.h"
 #include "absl/base/macros.h"
 #include "absl/container/internal/common.h"
 #include "absl/container/internal/common_policy_traits.h"
@@ -1078,12 +1077,9 @@ class btree_iterator_generation_info_enabled {

   template <typename Node>
   void assert_valid_generation(const Node *node) const {
-    if (node != nullptr && node->generation() != generation_) {
-      ABSL_INTERNAL_LOG(
-          FATAL,
-          "Attempting to use an invalidated iterator. The corresponding b-tree "
-          "container has been mutated since this iterator was constructed.");
-    }
+    // Attempting to use an invalidated iterator. The corresponding b-tree
+    // container has been mutated since this iterator was constructed.
+    assert(node == nullptr || node->generation() == generation_);
   }

Steps to reproduce the problem

I tried to repro on godbolt.org, but that correctly links in the full library. I did a straight up git clone into my vendor/ folder and started using it without any build config:

#include "absl/container/btree_set.h"

struct blockmap_btree_entry {
    uint32_t time_sec;
    uint32_t blockno;
};
absl::btree_multiset<blockmap_btree_entry> btree = ...

What version of Abseil are you using?

20240116.2

What operating system and version are you using?

Linux, custom Gentoo

What compiler and version are you using?

gcc version 12.3.1 20230825 (Gentoo 12.3.1_p20230825 p2)
clang version 16.0.6

What build system are you using?

GNU Make 4.4.1

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions