Disable _ASN_STACK_OVERFLOW_CHECK if building with Asan enabled
Related: OS#6025 Change-Id: I2dda4720f3ea5a023d340863db177e6334beeaa3
This commit is contained in:
parent
5cdcaffc15
commit
3e483e5950
|
@ -108,9 +108,34 @@ static inline void ASN_DEBUG(const char *fmt, ...) { (void)fmt; }
|
|||
/*
|
||||
* Check stack against overflow, if limit is set.
|
||||
*/
|
||||
|
||||
/* Since GCC 13, AddressSanitizer started defaulting to
|
||||
* ASAN_OPTIONS="detect_stack_use_after_return=1", which makes this check
|
||||
* fail due to apparently jumping stack pointers.
|
||||
* Hence, disable this check if building with ASan, as documented in:
|
||||
* GCC: https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
|
||||
* Clang: https://clang.llvm.org/docs/AddressSanitizer.html#conditional-compilation-with-has-feature-address-sanitizer
|
||||
*/
|
||||
#if defined(__SANITIZE_ADDRESS__)
|
||||
#define _ASN_SANITIZE_ENABLED 1
|
||||
#elif defined(__has_feature)
|
||||
#if __has_feature(address_sanitizer)
|
||||
#define _ASN_SANITIZE_ENABLED 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define _ASN_DEFAULT_STACK_MAX (30000)
|
||||
|
||||
#if defined(_ASN_SANITIZE_ENABLED)
|
||||
static inline int
|
||||
_ASN_STACK_OVERFLOW_CHECK(asn_codec_ctx_t *ctx) {
|
||||
(void)ctx;
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static inline int
|
||||
_ASN_STACK_OVERFLOW_CHECK(asn_codec_ctx_t *ctx) {
|
||||
|
||||
if(ctx && ctx->max_stack_size) {
|
||||
|
||||
/* ctx MUST be allocated on the stack */
|
||||
|
@ -126,6 +151,7 @@ _ASN_STACK_OVERFLOW_CHECK(asn_codec_ctx_t *ctx) {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue