Hi, On Fri, 2 Jan 2015 22:29:01, Jakub Jelinek wrote: > > On Fri, Jan 02, 2015 at 10:06:29PM +0100, Bernd Edlinger wrote: >> OK, I will do that. >> I removed the __tsan_vptr_update stuff from the patch, for now. > > Guess we should ask Dmitry about that. > >> It will probably be difficult for me to find a test case for this, >> because I am not really sure what __tsan_vptr_update is actually good for, >> (i.e. the use case). > >> I think I should also change the function type of BUILT_IN_READ_RANGE >> and BUILT_IN_WRITE_RANGE to BT_FN_VOID_PTR_SIZE? > > You should use BT_FN_VOID_PTR_PTRMODE for those instead, and you don't need to > initialize it in asan.c - it is already initialized there. > size_t might be a different integer type from uptr. > > Jakub
Dmitry, while I wrote this patch, I became aware of a minor flaw in GCC's instrumentation of __tsan_vptr_update. That is, currently we pass only the address of the vptr that is about to be written to this function, but the second parameter, the value that will be written, is always garbage. Jakub asked for a test case, but I am not sure about what is the use case, where this would make a difference. Can you shed some light on this? Thanks. Jakub, I changed the function type to BT_FN_VOID_PTR_PTRMODE, is the patch OK now? Thanks Bernd.
gcc/ChangeLog: 2015-01-02 Bernd Edlinger <bernd.edlin...@hotmail.de> Instrument bit field and unaligned accesses for TSAN. * sanitizer.def (BUILT_IN_TSAN_READ_RANGE): New built-in function. (BUILT_IN_TSAN_WRITE_RANGE): New built-in function. * tsan.c (instrument_expr): Handle COMPONENT_REF and BIT_FIELD_REF. Use BUILT_IN_TSAN_READ_RANGE and BUILT_IN_TSAN_WRITE_RANGE for unaligned memory regions. testsuite/ChangeLog: 2015-01-02 Bernd Edlinger <bernd.edlin...@hotmail.de> * c-c++-common/tsan/bitfield_race.c: New testcase. * g++.dg/tsan/aligned_vs_unaligned_race.C: Fixed.
patch-tsan-bitfields.diff
Description: Binary data