id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 13092,"Serializing pointer makes sanitizer complain about ""reference binding to misaligned address""",fiesh@…,Robert Ramey,"Consider the following program: {{{ #include #include #include #include #include struct S { int i; char c; template void serialize(Archive & ar, const unsigned int version) { ar & i; ar & c; } }; int main() { const auto s0 = std::make_shared(); s0->i = 42; s0->c = 'c'; std::stringstream ss; { boost::archive::text_oarchive oa(ss); oa << s0; } std::shared_ptr s1; { boost::archive::text_iarchive ia(ss); ia >> s1; } return 0; } }}} What is important is that we use a pointer to the struct. I then get the following output, which seems to be a real issue probably mitigated by x86's lax requirements on alignment: {{{ % g++ -lboost_serialization -fsanitize=address -fsanitize=leak -fsanitize=undefined -fsanitize=shift -fsanitize=integer-divide-by-zero -fsanitize=unreachable -fsanitize=vla-bound -fsanitize=null -fsanitize=return -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment -fsanitize=object-size -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=nonnull-attribute -fsanitize=returns-nonnull-attribute -fsanitize=bool -fsanitize=enum -fno-sanitize=vptr t.cpp&& LD_PRELOAD=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/libasan.so ./a.out % LD_PRELOAD=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/libasan.so ./a.out /usr/include/boost/archive/detail/iserializer.hpp:540:19: runtime error: reference binding to misaligned address 0x000000000002 for type 'struct S', which requires 4 byte alignment 0x000000000002: note: pointer points here /usr/include/boost/archive/detail/iserializer.hpp:541:67: runtime error: reference binding to misaligned address 0x000000000002 for type 'const struct S', which requires 4 byte alignment 0x000000000002: note: pointer points here % LD_PRELOAD=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/libasan.so ./a.out % LD_PRELOAD=/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/libasan.so ./a.out /usr/include/boost/archive/detail/iserializer.hpp:540:19: runtime error: reference binding to misaligned address 0x000000000002 for type 'struct S', which requires 4 byte alignment 0x000000000002: note: pointer points here /usr/include/boost/archive/detail/iserializer.hpp:541:67: runtime error: reference binding to misaligned address 0x000000000002 for type 'const struct S', which requires 4 byte alignment 0x000000000002: note: pointer points here }}} Note how it only occurs sometimes, probably depending on what memory address happened to have been returned. ",Bugs,new,To Be Determined,serialization,Boost 1.63.0,Problem,,,