Skip to content

cmake: remove error_code.cc from osdc to fix ODR violation#64259

Merged
tchaikov merged 1 commit intoceph:mainfrom
tchaikov:wip-cmake-osdc-without-error_code
Jul 14, 2025
Merged

cmake: remove error_code.cc from osdc to fix ODR violation#64259
tchaikov merged 1 commit intoceph:mainfrom
tchaikov:wip-cmake-osdc-without-error_code

Conversation

@tchaikov
Copy link
Contributor

Fix AddressSanitizer ODR (One Definition Rule) violation caused by 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 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

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

@tchaikov tchaikov mentioned this pull request Jun 30, 2025
14 tasks
@tchaikov
Copy link
Contributor Author

tchaikov commented Jul 1, 2025

jenkins test make check arm64

@tchaikov
Copy link
Contributor Author

@ceph/core hello maintainers, could you please help review this change?

Copy link
Contributor

@Matan-B Matan-B left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, as we have 4 different error_code.cc implementations throughout the repo we should probably use "osdc/error_code.cc" in the commit message.

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>
@tchaikov tchaikov force-pushed the wip-cmake-osdc-without-error_code branch from 31677f3 to 291b40e Compare July 14, 2025 01:27
@tchaikov
Copy link
Contributor Author

nit, as we have 4 different error_code.cc implementations throughout the repo we should probably use "osdc/error_code.cc" in the commit message.

sure. replaced error_code.cc with osdc/error_code.cc in the commit message.

@tchaikov
Copy link
Contributor Author

changelog

  • replaced all occurrences of error_code.cc with osdc/error_code.cc in the commit message.

@tchaikov tchaikov merged commit 8f971cf into ceph:main Jul 14, 2025
13 checks passed
@tchaikov tchaikov deleted the wip-cmake-osdc-without-error_code branch July 14, 2025 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants