Bug 1599024 - Don't crash when reading bad hangentry type r=froydnj

Fairly simple. We should fail gracefully and delete the file if it
appears to be corrupted. I wanted to see an example of a corrupted
permahang file before fixing this (it's scoped to nightly only, and
I wanted to make sure there wasn't a bug in how we're writing
these.) The example file was just filled with zeroes at the end. This
suggests to me our write calls succeeded when we wrote it, but the
OS didn't get a chance to flush its buffers to disk (but it did
reserve the required space on disk). I'm not familiar enough with
the inner workings of filesystems or the underlying drivers to
know if this is plausible or if they should have stronger guarantees
of atomicity, but it's good enough for me to conclude that the one
instance of a bad last_permahang.bin file I've seen is not directly
due to a bug in the writing code.

Differential Revision: https://phabricator.services.mozilla.com/D67645

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Doug Thayer 2020-03-20 20:09:11 +00:00
Родитель 11a79be1b6
Коммит 55ce557905
1 изменённых файлов: 1 добавлений и 1 удалений

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

@ -551,7 +551,7 @@ Result<Ok, nsresult> ReadEntry(PRFileDesc* aFile, HangStack& aStack) {
break;
}
default:
MOZ_CRASH("Unsupported HangEntry type?");
return Err(NS_ERROR_UNEXPECTED);
}
return Ok();
}