mirror of
https://github.com/corda/corda.git
synced 2025-01-03 19:54:13 +00:00
fix use of uninitialized values at root thread creation time when running in stress mode; allocate Thread::defaultHeap on the heap instead of as part of the Thread structure
This commit is contained in:
parent
5c99edd90e
commit
659555b6ce
@ -4096,11 +4096,13 @@ class MyProcessor: public Processor {
|
||||
{
|
||||
MyThread* t = static_cast<MyThread*>(vmt);
|
||||
|
||||
for (Reference* r = t->reference; r; r = r->next) {
|
||||
v->visit(&(r->target));
|
||||
}
|
||||
if (t->m->active) {
|
||||
for (Reference* r = t->reference; r; r = r->next) {
|
||||
v->visit(&(r->target));
|
||||
}
|
||||
|
||||
visitStack(t, v);
|
||||
visitStack(t, v);
|
||||
}
|
||||
}
|
||||
|
||||
virtual uintptr_t
|
||||
|
@ -1336,6 +1336,7 @@ Machine::Machine(System* system, Heap* heap, Finder* finder,
|
||||
weakReferences(0),
|
||||
tenuredWeakReferences(0),
|
||||
unsafe(false),
|
||||
active(false),
|
||||
heapPoolIndex(0)
|
||||
{
|
||||
populateJNITables(&javaVMVTable, &jniEnvVTable);
|
||||
@ -1386,12 +1387,12 @@ Thread::Thread(Machine* m, object javaThread, Thread* parent):
|
||||
heapIndex(0),
|
||||
heapOffset(0),
|
||||
protector(0),
|
||||
runnable(this)
|
||||
runnable(this),
|
||||
defaultHeap(static_cast<uintptr_t*>(m->system->allocate(HeapSizeInBytes))),
|
||||
heap(defaultHeap)
|
||||
#ifdef VM_STRESS
|
||||
, stress(false),
|
||||
defaultHeap(static_cast<uintptr_t*>(m->system->allocate(HeapSizeInBytes)))
|
||||
, stress(false)
|
||||
#endif // VM_STRESS
|
||||
, heap(defaultHeap)
|
||||
{
|
||||
if (parent == 0) {
|
||||
assert(this, m->rootThread == 0);
|
||||
@ -1399,6 +1400,7 @@ Thread::Thread(Machine* m, object javaThread, Thread* parent):
|
||||
|
||||
m->rootThread = this;
|
||||
m->unsafe = true;
|
||||
m->active = false;
|
||||
|
||||
if (not m->system->success(m->system->attach(&runnable))) {
|
||||
abort(this);
|
||||
@ -1494,6 +1496,7 @@ Thread::Thread(Machine* m, object javaThread, Thread* parent):
|
||||
|
||||
if (parent == 0) {
|
||||
enter(this, Thread::IdleState);
|
||||
m->active = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1098,6 +1098,12 @@ class Machine {
|
||||
#include "type-enums.cpp"
|
||||
};
|
||||
|
||||
enum State {
|
||||
UnsafeState,
|
||||
BootState,
|
||||
ActiveState
|
||||
};
|
||||
|
||||
Machine(System* system, Heap* heap, Finder* finder, Processor* processor);
|
||||
|
||||
~Machine() {
|
||||
@ -1136,6 +1142,7 @@ class Machine {
|
||||
object weakReferences;
|
||||
object tenuredWeakReferences;
|
||||
bool unsafe;
|
||||
bool active;
|
||||
JavaVMVTable javaVMVTable;
|
||||
JNIEnvVTable jniEnvVTable;
|
||||
uintptr_t* heapPool[HeapPoolSize];
|
||||
@ -1242,14 +1249,11 @@ class Thread {
|
||||
unsigned heapOffset;
|
||||
Protector* protector;
|
||||
Runnable runnable;
|
||||
#ifdef VM_STRESS
|
||||
bool stress;
|
||||
uintptr_t* defaultHeap;
|
||||
uintptr_t* heap;
|
||||
#else // not VM_STRESS
|
||||
uintptr_t* heap;
|
||||
uintptr_t defaultHeap[HeapSizeInWords];
|
||||
#endif // not VM_STRESS
|
||||
#ifdef VM_STRESS
|
||||
bool stress;
|
||||
#endif // VM_STRESS
|
||||
};
|
||||
|
||||
inline object
|
||||
|
Loading…
Reference in New Issue
Block a user