mirror of
https://github.com/corda/corda.git
synced 2025-01-21 03:55:00 +00:00
fix isThunkUnsafeStack
This function was broken in two different ways: 1. It only checked MyProcessor::thunks, not MyProcessor::bootThunks. It needs to check both. 2. When checking MyProcessor::thunks, it used fields from MyProcessor::bootThunks instead of from the same thunk collection. This fixes both problems.
This commit is contained in:
parent
ea797fd03c
commit
7ea6036842
@ -7750,26 +7750,24 @@ class MyProcessor: public Processor {
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isThunk(MyThread* t, void* ip)
|
isThunk(MyProcessor::ThunkCollection* thunks, void* ip)
|
||||||
{
|
{
|
||||||
MyProcessor* p = processor(t);
|
uint8_t* thunkStart = thunks->default_.start;
|
||||||
|
uint8_t* thunkEnd = thunks->table.start
|
||||||
uint8_t* thunkStart = p->thunks.default_.start;
|
+ (thunks->table.length * ThunkCount);
|
||||||
uint8_t* thunkEnd = p->thunks.table.start
|
|
||||||
+ (p->thunks.table.length * ThunkCount);
|
|
||||||
|
|
||||||
uint8_t* bootThunkStart = p->bootThunks.default_.start;
|
|
||||||
uint8_t* bootThunkEnd = p->bootThunks.table.start
|
|
||||||
+ (p->bootThunks.table.length * ThunkCount);
|
|
||||||
|
|
||||||
return (reinterpret_cast<uintptr_t>(ip)
|
return (reinterpret_cast<uintptr_t>(ip)
|
||||||
>= reinterpret_cast<uintptr_t>(thunkStart)
|
>= reinterpret_cast<uintptr_t>(thunkStart)
|
||||||
and reinterpret_cast<uintptr_t>(ip)
|
and reinterpret_cast<uintptr_t>(ip)
|
||||||
< reinterpret_cast<uintptr_t>(thunkEnd))
|
< reinterpret_cast<uintptr_t>(thunkEnd));
|
||||||
or (reinterpret_cast<uintptr_t>(ip)
|
}
|
||||||
>= reinterpret_cast<uintptr_t>(bootThunkStart)
|
|
||||||
and reinterpret_cast<uintptr_t>(ip)
|
bool
|
||||||
< reinterpret_cast<uintptr_t>(bootThunkEnd));
|
isThunk(MyThread* t, void* ip)
|
||||||
|
{
|
||||||
|
MyProcessor* p = processor(t);
|
||||||
|
|
||||||
|
return isThunk(&(p->thunks), ip) or isThunk(&(p->bootThunks), ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -7782,37 +7780,43 @@ isThunkUnsafeStack(MyProcessor::Thunk* thunk, void* ip)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isThunkUnsafeStack(MyThread* t, void* ip)
|
isThunkUnsafeStack(MyProcessor::ThunkCollection* thunks, void* ip)
|
||||||
{
|
{
|
||||||
if (isThunk(t, ip)) {
|
const unsigned NamedThunkCount = 4;
|
||||||
MyProcessor* p = processor(t);
|
|
||||||
|
|
||||||
const unsigned NamedThunkCount = 4;
|
MyProcessor::Thunk table[NamedThunkCount + ThunkCount];
|
||||||
|
|
||||||
MyProcessor::Thunk thunks[NamedThunkCount + ThunkCount];
|
table[0] = thunks->default_;
|
||||||
|
table[1] = thunks->defaultVirtual;
|
||||||
thunks[0] = p->thunks.default_;
|
table[2] = thunks->native;
|
||||||
thunks[1] = p->thunks.defaultVirtual;
|
table[3] = thunks->aioob;
|
||||||
thunks[2] = p->thunks.native;
|
|
||||||
thunks[3] = p->thunks.aioob;
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < ThunkCount; ++i) {
|
for (unsigned i = 0; i < ThunkCount; ++i) {
|
||||||
new (thunks + NamedThunkCount + i) MyProcessor::Thunk
|
new (table + NamedThunkCount + i) MyProcessor::Thunk
|
||||||
(p->thunks.table.start + (i * p->bootThunks.table.length),
|
(thunks->table.start + (i * thunks->table.length),
|
||||||
p->thunks.table.frameSavedOffset,
|
thunks->table.frameSavedOffset,
|
||||||
p->bootThunks.table.length);
|
thunks->table.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned i = 0; i < NamedThunkCount + ThunkCount; ++i) {
|
for (unsigned i = 0; i < NamedThunkCount + ThunkCount; ++i) {
|
||||||
if (isThunkUnsafeStack(thunks + i, ip)) {
|
if (isThunkUnsafeStack(table + i, ip)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
isThunkUnsafeStack(MyThread* t, void* ip)
|
||||||
|
{
|
||||||
|
MyProcessor* p = processor(t);
|
||||||
|
|
||||||
|
return isThunk(t, ip)
|
||||||
|
and (isThunkUnsafeStack(&(p->thunks), ip)
|
||||||
|
or isThunkUnsafeStack(&(p->bootThunks), ip));
|
||||||
|
}
|
||||||
|
|
||||||
object
|
object
|
||||||
findCallNode(MyThread* t, void* address)
|
findCallNode(MyThread* t, void* address)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user