[PATCH] ADT: Remove misaligned pointeres from DenseMapInfo

Richard Smith richard at metafoo.co.uk
Thu Jan 8 15:15:29 PST 2015


On Thu, Jan 8, 2015 at 3:04 PM, Chandler Carruth <chandlerc at google.com>
wrote:

>
> On Thu, Jan 8, 2015 at 2:59 PM, Alexey Samsonov <vonosmas at gmail.com>
> wrote:
>
>>   This is where UBSan reports an error - P is not a pointer to an actual
>> object, it's a fake value (0xfffff....), which is not even
>>   properly aligned.
>>
>
> As I've said before, I believe UBSan is incorrect to report an error at
> this point. I don't believe the cast to a pointer is UB, I believe using
> that pointer for anything other than casting back to an integer is UB. We
> can't even compare it to another pointer (such a compare would also produce
> 'false', even for comparison with itself).
>

It looks like what's happening is that this invalid pointer value is being
upcast, and that is what UBSan is complaining about. If so, I think UBSan
is right, but the bug is in DenseMapInfo<AssertingVH<T>>: it shouldn't be
assuming that DenseMapInfo<T*>'s getEmptyKey produces a valid pointer to a
T; it obviously cannot do so.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150108/fce03c1d/attachment.html>


More information about the llvm-commits mailing list