]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: remove osdc/error_code.cc from osdc to fix ODR violation 64259/head
authorKefu Chai <tchaikov@gmail.com>
Mon, 30 Jun 2025 07:54:14 +0000 (15:54 +0800)
committerKefu Chai <tchaikov@gmail.com>
Mon, 14 Jul 2025 01:27:42 +0000 (09:27 +0800)
Fix AddressSanitizer ODR (One Definition Rule) violation caused by
osdc/error_code.cc being compiled into both the osdc library and
ceph-common library.

The violation occurred because osdc_error_category was defined in
both the rbd binary (via osdc) and libceph-common.so, creating
duplicate symbols at runtime.

Since all targets that link against osdc also link against
ceph-common, removing osdc/error_code.cc from osdc doesn't break the
build while eliminating the duplicate definition.

ASan error sample:

```
  ==857433==ERROR: AddressSanitizer: odr-violation (0x5612ad665760):
    [1] size=22 'typeinfo name for osdc_error_category' /home/jenkins-build/build/workspace/ceph-pull-requests/src/osdc/error_code.cc in /home/jenkins-build/build/workspace/ceph-pull-requests/build/bin/rbd
    [2] size=22 'typeinfo name for osdc_error_category' /home/jenkins-build/build/workspace/ceph-pull-requests/src/osdc/error_code.cc in /home/jenkins-build/build/workspace/ceph-pull-requests/build/lib/libceph-common.so.2
  These globals were registered at these points:
    [1]:
      #0 0x5612acd62c88 in __asan_register_globals (/home/jenkins-build/build/workspace/ceph-pull-requests/build/bin/rbd+0x815c88) (BuildId: 62a02cbbf3426e5470e16372e3b53a18cb18ce0f)
      #1 0x5612acd63d59 in __asan_register_elf_globals (/home/jenkins-build/build/workspace/ceph-pull-requests/build/bin/rbd+0x816d59) (BuildId: 62a02cbbf3426e5470e16372e3b53a18cb18ce0f)
      #2 0x7f28d3b02eba in call_init csu/../csu/libc-start.c:145:3
      #3 0x7f28d3b02eba in __libc_start_main csu/../csu/libc-start.c:379:5
```

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/osdc/CMakeLists.txt

index 637ce32755583ae2e6cc4830907dc067ce1fcc3a..38d4dfd35652e791596bdc6b9d21519ae440c75b 100644 (file)
@@ -1,8 +1,7 @@
 set(osdc_files
   Filer.cc
-  ObjectCacher.cc
-  error_code.cc)
-# Objecter.cc and Striper.cc are part of libcommon
+  ObjectCacher.cc)
+# error_code.cc, Objecter.cc and Striper.cc are part of libcommon
 add_library(osdc STATIC ${osdc_files})
 target_link_libraries(osdc ceph-common)
 if(WITH_EVENTTRACE)