Skip to content

Commit 291b40e

Browse files
committed
cmake: remove osdc/error_code.cc from osdc to fix ODR violation
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) ceph#1 0x5612acd63d59 in __asan_register_elf_globals (/home/jenkins-build/build/workspace/ceph-pull-requests/build/bin/rbd+0x816d59) (BuildId: 62a02cbbf3426e5470e16372e3b53a18cb18ce0f) ceph#2 0x7f28d3b02eba in call_init csu/../csu/libc-start.c:145:3 ceph#3 0x7f28d3b02eba in __libc_start_main csu/../csu/libc-start.c:379:5 ``` Signed-off-by: Kefu Chai <[email protected]>
1 parent d35e1b5 commit 291b40e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/osdc/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
set(osdc_files
22
Filer.cc
3-
ObjectCacher.cc
4-
error_code.cc)
5-
# Objecter.cc and Striper.cc are part of libcommon
3+
ObjectCacher.cc)
4+
# error_code.cc, Objecter.cc and Striper.cc are part of libcommon
65
add_library(osdc STATIC ${osdc_files})
76
target_link_libraries(osdc ceph-common)
87
if(WITH_EVENTTRACE)

0 commit comments

Comments
 (0)