diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-07-06 09:39:04 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-07-10 13:11:07 +0900 |
commit | b1b8172328e384008bd17431335f512536c297f8 (patch) | |
tree | 79ddc2d7d09d3c6a3330b1a5d62460e4078625e1 | |
parent | ec303e49afeee9f6070d06f55650bbd373c33dd6 (diff) |
Add `asan_unpoisoning_object` to execute the block with unpoisoning
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6092
-rw-r--r-- | gc.c | 27 |
1 files changed, 19 insertions, 8 deletions
@@ -1409,6 +1409,21 @@ asan_unpoison_object_temporary(VALUE obj) return ptr; } +static inline void * +asan_poison_object_restore(VALUE obj, void *ptr) +{ + if (ptr) { + asan_poison_object(obj); + } + return NULL; +} + +#define asan_unpoisoning_object(obj) \ + for (void *poisoned = asan_unpoison_object_temporary(obj), \ + *unpoisoning = &poisoned; /* flag to loop just once */ \ + unpoisoning; \ + unpoisoning = asan_poison_object_restore(obj, poisoned)) + #define FL_CHECK2(name, x, pred) \ ((RGENGC_CHECK_MODE && SPECIAL_CONST_P(x)) ? \ (rb_bug(name": SPECIAL_CONST (%p)", (void *)(x)), 0) : (pred)) @@ -13945,14 +13960,10 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU const char * rb_raw_obj_info(char *const buff, const size_t buff_size, VALUE obj) { - void *poisoned = asan_unpoison_object_temporary(obj); - - size_t pos = rb_raw_obj_info_common(buff, buff_size, obj); - pos = rb_raw_obj_info_buitin_type(buff, buff_size, obj, pos); - if (pos >= buff_size) {} // truncated - - if (poisoned) { - asan_poison_object(obj); + asan_unpoisoning_object(obj) { + size_t pos = rb_raw_obj_info_common(buff, buff_size, obj); + pos = rb_raw_obj_info_buitin_type(buff, buff_size, obj, pos); + if (pos >= buff_size) {} // truncated } return buff; |