make ext/coverage ASAN friendly

This commit is contained in:
Aaron Patterson 2020-09-25 14:55:12 -07:00 коммит произвёл Aaron Patterson
Родитель 18b3f0f54c
Коммит b328b83026
1 изменённых файлов: 8 добавлений и 0 удалений

Просмотреть файл

@ -11,6 +11,7 @@
#include "gc.h"
#include "internal/hash.h"
#include "internal/thread.h"
#include "internal/sanitizers.h"
#include "ruby.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;
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) {
const rb_method_entry_t *me = (rb_method_entry_t *) v;
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);
}
}
if (poisoned) {
asan_poison_object(v);
}
}
return 0;
}