Bug 1124397 - More crash diagnostics. r=nbp

--HG--
extra : rebase_source : 77a6b4c0d179ca7dde85e3094f1754b3703a7d3d
This commit is contained in:
Jan de Mooij 2016-04-18 13:14:22 +02:00
Родитель 81900ec394
Коммит 3b4f24a914
1 изменённых файлов: 31 добавлений и 0 удалений

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

@ -105,6 +105,37 @@ void
AssemblerX86Shared::executableCopy(void* buffer)
{
masm.executableCopy(buffer);
// Crash diagnostics for bug 1124397. Check the code buffer has not been
// poisoned with 0xE5 bytes.
static const size_t MinPoisoned = 16;
const uint8_t* bytes = (const uint8_t*)buffer;
size_t len = size();
for (size_t i = 0; i < len; i += MinPoisoned) {
if (bytes[i] != 0xE5)
continue;
size_t startOffset = i;
while (startOffset > 0 && bytes[startOffset - 1] == 0xE5)
startOffset--;
size_t endOffset = i;
while (endOffset + 1 < len && bytes[endOffset + 1] == 0xE5)
endOffset++;
if (endOffset - startOffset < MinPoisoned)
continue;
volatile uintptr_t dump[5];
blackbox = dump;
blackbox[0] = uintptr_t(0xABCD4321);
blackbox[1] = uintptr_t(len);
blackbox[2] = uintptr_t(startOffset);
blackbox[3] = uintptr_t(endOffset);
blackbox[4] = uintptr_t(0xFFFF8888);
MOZ_CRASH("Corrupt code buffer");
}
}
void