Skip to content

UBSAN: downcast of address in interface_oarchive #108

@jeking3

Description

@jeking3

When building Boost.Serialization with UBSAN enabled I am seeing this error. I am using the docker build environment in boostorg/boost#184 to make the environment, and then you can see the command below and the issue it finds:

boost@9423c57fd56c:/boost/libs/serialization/test$ UBSAN_OPTIONS=print_stacktrace=1 ../../../b2 toolset=gcc-7 cxxstd=03 cxxflags=-fno-omit-frame-pointer cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined linkflags=-fno-sanitize-recover=undefined linkflags=-fuse-ld=gold variant=debug -j3 test_bitset_xml_archive
Performing configuration checks

    - default address-model    : 64-bit (cached)
    - default architecture     : x86 (cached)
    - symlinks supported       : yes (cached)
...patience...
...found 2246 targets...
...updating 2 targets...
testing.capture-output ../../../bin.v2/libs/serialization/test/test_bitset_xml_archive.test/gcc-7/debug/cxxstd-03-iso/test_bitset_xml_archive.run
====== BEGIN OUTPUT ======
../../../boost/archive/detail/interface_oarchive.hpp:47:16: runtime error: downcast of address 0x7ffff8978910 which does not point to an object of type 'xml_oarchive'
0x7ffff8978910: note: object is of type 'boost::archive::xml_oarchive_impl<boost::archive::xml_oarchive>'
 c2 fb bf ab  00 38 5e 27 e9 7f 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'boost::archive::xml_oarchive_impl<boost::archive::xml_oarchive>'
    #0 0x7fe9275a29d0 in boost::archive::detail::interface_oarchive<boost::archive::xml_oarchive>::This() (/boost/bin.v2/libs/serialization/build/gcc-7/debug/cxxstd-03-iso/libboost_serialization.so.1.68.0+0x1859d0)
    #1 0x7fe92759ead0 in boost::archive::basic_xml_oarchive<boost::archive::xml_oarchive>::init() (/boost/bin.v2/libs/serialization/build/gcc-7/debug/cxxstd-03-iso/libboost_serialization.so.1.68.0+0x181ad0)
    #2 0x7fe9275a1e76 in boost::archive::xml_oarchive_impl<boost::archive::xml_oarchive>::xml_oarchive_impl(std::ostream&, unsigned int) (/boost/bin.v2/libs/serialization/build/gcc-7/debug/cxxstd-03-iso/libboost_serialization.so.1.68.0+0x184e76)
    #3 0x55f563efb2f3 in boost::archive::xml_oarchive::xml_oarchive(std::ostream&, unsigned int) ../../../boost/archive/xml_oarchive.hpp:122
    #4 0x55f563ef8944 in test_main(int, char**) /boost/libs/serialization/test/test_bitset.cpp:47
    #5 0x55f563ef85be in main /boost/libs/serialization/test/test_tools.hpp:200
    #6 0x7fe925d86b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #7 0x55f563ef82c9 in _start (/boost/bin.v2/libs/serialization/test/test_bitset_xml_archive.test/gcc-7/debug/cxxstd-03-iso/test_bitset_xml_archive+0xe2c9)


EXIT STATUS: 1
====== END OUTPUT ======

    LD_LIBRARY_PATH="/boost/bin.v2/libs/filesystem/build/gcc-7/debug/cxxstd-03-iso:/boost/bin.v2/libs/serialization/build/gcc-7/debug/cxxstd-03-iso:/boost/bin.v2/libs/system/build/gcc-7/debug/cxxstd-03-iso:/usr/bin:/usr/lib:/usr/lib32:/usr/lib64:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH

    status=0
    if test $status -ne 0 ; then
        echo Skipping test execution due to testing.execute=off
        exit 0
    fi
     "../../../bin.v2/libs/serialization/test/test_bitset_xml_archive.test/gcc-7/debug/cxxstd-03-iso/test_bitset_xml_archive"   > "../../../bin.v2/libs/serialization/test/test_bitset_xml_archive.test/gcc-7/debug/cxxstd-03-iso/test_bitset_xml_archive.output" 2>&1 < /dev/null
    status=$?
    echo >> "../../../bin.v2/libs/serialization/test/test_bitset_xml_archive.test/gcc-7/debug/cxxstd-03-iso/test_bitset_xml_archive.output"
    echo EXIT STATUS: $status >> "../../../bin.v2/libs/serialization/test/test_bitset_xml_archive.test/gcc-7/debug/cxxstd-03-iso/test_bitset_xml_archive.output"
    if test $status -eq 0 ; then
        cp "../../../bin.v2/libs/serialization/test/test_bitset_xml_archive.test/gcc-7/debug/cxxstd-03-iso/test_bitset_xml_archive.output" "../../../bin.v2/libs/serialization/test/test_bitset_xml_archive.test/gcc-7/debug/cxxstd-03-iso/test_bitset_xml_archive.run"
    fi
    verbose=0
    if test $status -ne 0 ; then
        verbose=1
    fi
    if test $verbose -eq 1 ; then
        echo ====== BEGIN OUTPUT ======
        cat "../../../bin.v2/libs/serialization/test/test_bitset_xml_archive.test/gcc-7/debug/cxxstd-03-iso/test_bitset_xml_archive.output"
        echo ====== END OUTPUT ======
    fi
    exit $status

...failed testing.capture-output ../../../bin.v2/libs/serialization/test/test_bitset_xml_archive.test/gcc-7/debug/cxxstd-03-iso/test_bitset_xml_archive.run...
...failed updating 1 target...
...skipped 1 target...

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