Open bjosv opened 2 years ago
thanks for reporting. This was not discussed earlier, so need to look into it. Also, if this is false-positive (i.e. reported by UBSan
`without any real undefined behavior at run-time), we may just need to document this.
This issue was marked as stale due to lack of activity.
Reopening it, for now, we can discuss it in the next community meeting how to handle this.
@lalitb So… How did the meeting go?
When using
nostd::shared_ptr
and building with an undefined behavior detector there are indications of vptr issues. It's an use of an object whose vptr indicates that it is of the wrong dynamic type. The issue can be triggered by the existing tests as well:Steps to reproduce
It seems that the
shared_ptr_wrapper
is of typenostd::shared_ptr<T>::shared_ptr_wrapper
while other.wrapper() is anostd::shared_ptr<U>
.This gives that shared_ptr_wrapper::MoveTo will store a
nostd::shared_ptr<U>::shared_ptr_wrapper
inside anostd::shared_ptr<T>::buffer_
, but it will access it as anostd::shared_ptr<T>::shared_ptr_wrapper
which causes this UBSAN error.I have not found any discussions or issues regarding this, but the question is if it's a know issue or as design?
Additional context The specific check that triggers is
-fsanitize=vptr
which is part of the general group-fsanitize=undefined