diff mbox

Document -fsanitize=vptr (PR sanitizer/64706)

Message ID 20150121213347.GU1746@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Jan. 21, 2015, 9:33 p.m. UTC
Hi!

I forgot to document this, is this ok for trunk or do you prefer some other
wording?

Slightly off-topic, what do you think about replacing *this ={v} {CLOBBER};
stmts in dtors of objects with virtual methods with storing of
NULL or some other value into the vtable pointer field, so that we would
(sometimes) catch member accesses and method calls after destruction?

2015-01-21  Jakub Jelinek  <jakub@redhat.com>

	PR sanitizer/64706
	* doc/invoke.texi (-fsanitize=vptr): Document.


	Jakub

Comments

Jason Merrill Jan. 21, 2015, 9:40 p.m. UTC | #1
On 01/21/2015 04:33 PM, Jakub Jelinek wrote:
> +This option enables instrumentation of C++ member function calls, member
> +accesses and some downcasts and upcasts, to verify the referenced object

Instead of "downcasts and upcasts" I'd write "conversions between 
pointers to base and derived classes"; Bjarne specifically avoided "up" 
and "down" because they are unclear.

Jason
Jason Merrill Jan. 21, 2015, 9:41 p.m. UTC | #2
On 01/21/2015 04:33 PM, Jakub Jelinek wrote:
> Slightly off-topic, what do you think about replacing *this ={v} {CLOBBER};
> stmts in dtors of objects with virtual methods with storing of
> NULL or some other value into the vtable pointer field, so that we would
> (sometimes) catch member accesses and method calls after destruction?

The clobber statement clobbers the entire object, not just the vptr, but 
setting the vptr to null when -fsanitize=vptr makes sense to me.

Jason
diff mbox

Patch

--- gcc/doc/invoke.texi.jj	2015-01-20 11:51:41.000000000 +0100
+++ gcc/doc/invoke.texi	2015-01-21 12:49:14.679867871 +0100
@@ -5761,6 +5761,13 @@  This option enables instrumentation of l
 a value outside the range of values for the enum type is loaded,
 a run-time error is issued.
 
+@item -fsanitize=vptr
+@opindex fsanitize=vptr
+
+This option enables instrumentation of C++ member function calls, member
+accesses and some downcasts and upcasts, to verify the referenced object
+has the correct dynamic type.
+
 @end table
 
 While @option{-ftrapv} causes traps for signed overflows to be emitted,