[PATCH] [UBsan] Skip -fsanitize=vptr instrumentations when the pointer value is null

Byoungyoung Lee byoungyoung at chromium.org
Thu Jul 17 11:09:49 PDT 2014


rsmith@ - could you please land this patch as I don't have a commit permission?

================
Comment at: lib/CodeGen/CGExpr.cpp:553-554
@@ +552,4 @@
+
+      // Skip Vptr checks when the pointer value is null. This is redundant if
+      // -fsanitize=null is used.
+      // FIXME: Add optional flags.
----------------
Richard Smith wrote:
> Nit: lowercase 'v'.
> 
> It'd be nice to expand on this a bit: a null pointer here is undefined behavior, but if -fsanitize=null is not enabled, we don't want to change the behavior of code in that case, so that the user doesn't have to fix all their null pointer bugs before they can find their type mismatch bugs (which are likely to be more serious).
Thanks Richard for the comments! Let me change the patch as you suggested.

I was confused on your comment in -fsanitize=null, which says "When performing a pointer downcast, it's OK if the value is null. Skip the remaining checks in that case". Is this mean that the down-casted null pointer is a result of "defined behavior", or did you mean something else? From my shallow understanding and your review comments, it seems "undefined" though.

http://reviews.llvm.org/D4412






More information about the cfe-commits mailing list