Skip to content

Commit

Permalink
Protect stack direction detection and stack overflow checking against…
Browse files Browse the repository at this point in the history
… GCC

asan instrumentation (related to 83082).


git-svn-id: https://svn.r-project.org/R/trunk@85675 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
kalibera committed Dec 13, 2023
1 parent 53e6d9d commit a811921
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
16 changes: 11 additions & 5 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -26390,9 +26390,15 @@ else $as_nop

#define attribute_no_sanitizer_instrumentation
#ifdef __has_attribute
# undef attribute_no_sanitizer_instrumentation
# define attribute_no_sanitizer_instrumentation \
__attribute__((disable_sanitizer_instrumentation))
# if __has_attribute(disable_sanitizer_instrumentation)
# undef attribute_no_sanitizer_instrumentation
# define attribute_no_sanitizer_instrumentation \
__attribute__((disable_sanitizer_instrumentation))
# elif __has_attribute(no_sanitize)
# undef attribute_no_sanitizer_instrumentation
# define attribute_no_sanitizer_instrumentation \
__attribute__ ((no_sanitize ("address", "thread", "leak", "undefined")))
# endif
#endif

int attribute_no_sanitizer_instrumentation
Expand Down Expand Up @@ -27115,7 +27121,7 @@ _ACEOF
# flags.
r_save_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $r_verb"
(eval echo $as_me:27120: \"$ac_link\") >&5
(eval echo $as_me:27126: \"$ac_link\") >&5
r_c_v_output=`eval $ac_link 5>&1 2>&1 | grep -v 'Driving:'`
echo "$r_c_v_output" >&5
CFLAGS=$r_save_CFLAGS
Expand Down Expand Up @@ -27191,7 +27197,7 @@ _ACEOF
# flags.
r_save_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $r_cv_prog_c_v"
(eval echo $as_me:27196: \"$ac_link\") >&5
(eval echo $as_me:27202: \"$ac_link\") >&5
r_c_v_output=`eval $ac_link 5>&1 2>&1 | grep -v 'Driving:'`
echo "$r_c_v_output" >&5
CFLAGS=$r_save_CFLAGS
Expand Down
12 changes: 9 additions & 3 deletions m4/R.m4
Original file line number Diff line number Diff line change
Expand Up @@ -5125,9 +5125,15 @@ AC_CACHE_VAL([r_cv_cstack_direction],
#define attribute_no_sanitizer_instrumentation
#ifdef __has_attribute
# undef attribute_no_sanitizer_instrumentation
# define attribute_no_sanitizer_instrumentation \
__attribute__((disable_sanitizer_instrumentation))
# if __has_attribute(disable_sanitizer_instrumentation)
# undef attribute_no_sanitizer_instrumentation
# define attribute_no_sanitizer_instrumentation \
__attribute__((disable_sanitizer_instrumentation))
# elif __has_attribute(no_sanitize)
# undef attribute_no_sanitizer_instrumentation
# define attribute_no_sanitizer_instrumentation \
__attribute__ ((no_sanitize ("address", "thread", "leak", "undefined")))
# endif
#endif
int attribute_no_sanitizer_instrumentation
Expand Down
12 changes: 11 additions & 1 deletion src/include/Defn.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@
# if __has_attribute(disable_sanitizer_instrumentation)
# undef attribute_no_sanitizer_instrumentation
# define attribute_no_sanitizer_instrumentation \
__attribute__((disable_sanitizer_instrumentation))
__attribute__((disable_sanitizer_instrumentation))
# elif __has_attribute(no_sanitize)
# undef attribute_no_sanitizer_instrumentation
# define attribute_no_sanitizer_instrumentation \
__attribute__ ((no_sanitize ("address", "thread", "leak", "undefined")))
# endif
#endif

Expand Down Expand Up @@ -779,6 +783,12 @@ void SET_SCALAR_BVAL(SEXP x, Rbyte v);
# endif
#endif

#ifdef R_CheckStack
# if defined(__SANITIZE_ADDRESS__) || defined(__SANITIZE_THREAD__)
# undef R_CheckStack
# endif
#endif

#endif /* USE_RINTERNALS */

const char * Rf_translateCharFP(SEXP);
Expand Down

0 comments on commit a811921

Please sign in to comment.