diff --git a/src/compile.cpp b/src/compile.cpp index ee41dd9cb7..48ab0aebeb 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -5984,9 +5984,11 @@ class MyProcessor: public Processor { virtual void initVtable(Thread* t, object c) { + PROTECT(t, c); for (int i = classLength(t, c) - 1; i >= 0; --i) { - classVtable(t, c, i) = reinterpret_cast + void* thunk = reinterpret_cast (virtualThunk(static_cast(t), i)); + classVtable(t, c, i) = thunk; } } diff --git a/src/machine.cpp b/src/machine.cpp index 9b8ddb7c38..574b5ffd99 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -2439,6 +2439,8 @@ parseClass(Thread* t, const uint8_t* data, unsigned size) classLoader(t, class_), vtableLength); + PROTECT(t, real); + t->m->processor->initVtable(t, real); updateClassTables(t, real, class_);