-
- Downloads
c++: -fsanitize=vptr and -fstrong-eval-order. [PR95221]
With -fstrong-eval-order=all we evaluate the function address before the arguments. But this caused trouble with virtual functions and -fsanitize=vptr; we would do vptr sanitization as part of calculating the 'this' argument, and separately look at the vptr in order to find the function address. Without -fstrong-eval-order=all 'this' is evaluated first, but with that flag the function address is evaluated first, so we would access the null vptr before sanitizing it. Fixed by instrumenting the OBJ_TYPE_REF of a virtual function call instead of the 'this' argument. This issue suggests that we should be running the ubsan tests in multiple standard modes like the rest of the G++ testsuite, so I've made that change as well. gcc/cp/ChangeLog: * cp-ubsan.c (cp_ubsan_maybe_instrument_member_call): For a virtual call, instrument the OBJ_TYPE_REF. gcc/testsuite/ChangeLog: * g++.dg/ubsan/ubsan.exp: Use g++-dg-runtest. * c-c++-common/ubsan/bounds-13.c: Adjust. * c-c++-common/ubsan/bounds-2.c: Adjust. * c-c++-common/ubsan/div-by-zero-1.c: Adjust. * c-c++-common/ubsan/div-by-zero-6.c: Adjust. * c-c++-common/ubsan/div-by-zero-7.c: Adjust. * c-c++-common/ubsan/overflow-add-1.c: Adjust. * c-c++-common/ubsan/overflow-add-2.c: Adjust. * c-c++-common/ubsan/overflow-int128.c: Adjust. * c-c++-common/ubsan/overflow-sub-1.c: Adjust. * c-c++-common/ubsan/overflow-sub-2.c: Adjust. * g++.dg/ubsan/pr85029.C: Adjust. * g++.dg/ubsan/vptr-14.C: Adjust.
Showing
- gcc/cp/cp-ubsan.c 26 additions, 7 deletionsgcc/cp/cp-ubsan.c
- gcc/testsuite/c-c++-common/ubsan/bounds-13.c 1 addition, 0 deletionsgcc/testsuite/c-c++-common/ubsan/bounds-13.c
- gcc/testsuite/c-c++-common/ubsan/bounds-2.c 1 addition, 0 deletionsgcc/testsuite/c-c++-common/ubsan/bounds-2.c
- gcc/testsuite/c-c++-common/ubsan/div-by-zero-1.c 1 addition, 0 deletionsgcc/testsuite/c-c++-common/ubsan/div-by-zero-1.c
- gcc/testsuite/c-c++-common/ubsan/div-by-zero-6.c 1 addition, 0 deletionsgcc/testsuite/c-c++-common/ubsan/div-by-zero-6.c
- gcc/testsuite/c-c++-common/ubsan/div-by-zero-7.c 1 addition, 0 deletionsgcc/testsuite/c-c++-common/ubsan/div-by-zero-7.c
- gcc/testsuite/c-c++-common/ubsan/overflow-add-1.c 1 addition, 0 deletionsgcc/testsuite/c-c++-common/ubsan/overflow-add-1.c
- gcc/testsuite/c-c++-common/ubsan/overflow-add-2.c 1 addition, 0 deletionsgcc/testsuite/c-c++-common/ubsan/overflow-add-2.c
- gcc/testsuite/c-c++-common/ubsan/overflow-int128.c 1 addition, 0 deletionsgcc/testsuite/c-c++-common/ubsan/overflow-int128.c
- gcc/testsuite/c-c++-common/ubsan/overflow-sub-1.c 1 addition, 0 deletionsgcc/testsuite/c-c++-common/ubsan/overflow-sub-1.c
- gcc/testsuite/c-c++-common/ubsan/overflow-sub-2.c 1 addition, 0 deletionsgcc/testsuite/c-c++-common/ubsan/overflow-sub-2.c
- gcc/testsuite/g++.dg/ubsan/pr85029.C 1 addition, 1 deletiongcc/testsuite/g++.dg/ubsan/pr85029.C
- gcc/testsuite/g++.dg/ubsan/ubsan.exp 1 addition, 1 deletiongcc/testsuite/g++.dg/ubsan/ubsan.exp
- gcc/testsuite/g++.dg/ubsan/vptr-14.C 1 addition, 1 deletiongcc/testsuite/g++.dg/ubsan/vptr-14.C
Loading
Please register or sign in to comment