1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

make ext/coverage ASAN friendly

This commit is contained in:
Aaron Patterson 2020-09-25 14:55:12 -07:00 committed by Aaron Patterson
parent 18b3f0f54c
commit b328b83026
Notes: git 2020-09-29 00:21:01 +09:00

View file

@ -11,6 +11,7 @@
#include "gc.h" #include "gc.h"
#include "internal/hash.h" #include "internal/hash.h"
#include "internal/thread.h" #include "internal/thread.h"
#include "internal/sanitizers.h"
#include "ruby.h" #include "ruby.h"
#include "vm_core.h" #include "vm_core.h"
@ -150,6 +151,9 @@ method_coverage_i(void *vstart, void *vend, size_t stride, void *data)
VALUE ncoverages = *(VALUE*)data, v; VALUE ncoverages = *(VALUE*)data, v;
for (v = (VALUE)vstart; v != (VALUE)vend; v += stride) { for (v = (VALUE)vstart; v != (VALUE)vend; v += stride) {
void *poisoned = asan_poisoned_object_p(v);
asan_unpoison_object(v, false);
if (RB_TYPE_P(v, T_IMEMO) && imemo_type(v) == imemo_ment) { if (RB_TYPE_P(v, T_IMEMO) && imemo_type(v) == imemo_ment) {
const rb_method_entry_t *me = (rb_method_entry_t *) v; const rb_method_entry_t *me = (rb_method_entry_t *) v;
VALUE path, first_lineno, first_column, last_lineno, last_column; VALUE path, first_lineno, first_column, last_lineno, last_column;
@ -189,6 +193,10 @@ method_coverage_i(void *vstart, void *vend, size_t stride, void *data)
rb_hash_aset(methods, key, rcount); rb_hash_aset(methods, key, rcount);
} }
} }
if (poisoned) {
asan_poison_object(v);
}
} }
return 0; return 0;
} }