]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
include/ceph_assert.h: do not pack assert params if WITH_ASAN
authorKefu Chai <kchai@redhat.com>
Mon, 22 Oct 2018 08:41:45 +0000 (16:41 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 22 Oct 2018 15:01:36 +0000 (23:01 +0800)
commit3d0d24a228dd6a8259b9c04c6db470b42f5fdd1b
tree93b77f0416715038686c54cac7f01d1dc307cb49
parent5e12cef93008e12d092f4c1de5794304945b55fc
include/ceph_assert.h: do not pack assert params if WITH_ASAN

we pack the asset() params for smaller code size, but this creates a
inlined `assert_data_ctx` instance for every compilation unit which
call ceph_assert() defined in .h .

__PRETTY_FUNCTION__ is likely to be referenced by `assert_data_ctx`
sections which are included by different compiled object files. if the
ceph_assert() call is used by header file, then there will be multiple
`assert_data_ctx` sections sharing the same identifier. these sections are
defined as "COMDAT" group sections, i.e. common data sections. when linker
see multiple COMDAT sections with the same identifer, it will simply discard
the duplicated ones, and only keep a single copy of them. without enabling
ASan, GCC can always handle this problem just fine. but the dedup feature
does not work well with ASan. if ASan is enabled, and we link the objects
with the wrong order, some references will be pointing to the discarded
sections.

to address this issue, we could audit the link command line and inspect
all .o files to make sure they are properly ordered. but this is
non-trivial. as a workaround, in this change, the assert params are not
packed, and sent to the  __ceph_assert_fail() overrides which accepts
unpacked params directly, so the COMDAT section is not created.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/include/ceph_assert.h