Bug 1821008 - Add nyx abort macro and more debug messages. r=truber,glandium

Differential Revision: https://phabricator.services.mozilla.com/D171979
This commit is contained in:
Christian Holler (:decoder) 2023-03-14 07:50:36 +00:00
Родитель 920138cd5c
Коммит 3b82ba8433
3 изменённых файлов: 15 добавлений и 11 удалений

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

@ -68,12 +68,18 @@
# else
# define MOZ_FUZZING_NYX_DEBUG(x)
# endif
# define MOZ_FUZZING_NYX_ABORT(aMsg) \
do { \
MOZ_FUZZING_NYX_PRINT(aMsg); \
MOZ_REALLY_CRASH(__LINE__); \
} while (false);
#else
# define MOZ_FUZZING_NYX_RELEASE(id)
# define MOZ_FUZZING_NYX_GUARD(id)
# define MOZ_FUZZING_NYX_PRINT(aMsg)
# define MOZ_FUZZING_NYX_PRINTF(aFormat, ...)
# define MOZ_FUZZING_NYX_DEBUG(aMsg)
# define MOZ_FUZZING_NYX_ABORT(aMsg)
# define MOZ_FUZZING_HANDLE_CRASH_EVENT2(aType, aReason) \
do { \
} while (false)

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

@ -179,7 +179,7 @@ void IPCFuzzController::AddToplevelActor(PortName name, ProtocolId protocolId) {
MOZ_FUZZING_NYX_PRINTF(
"ERROR: [OnActorConnected] Unknown Top-Level Protocol: %s\n",
protocolName);
MOZ_REALLY_CRASH(__LINE__);
MOZ_FUZZING_NYX_ABORT("Unknown Top-Level Protocol\n");
}
uint8_t portIndex = result->second;
portNames[portIndex].push_back(name);
@ -228,7 +228,7 @@ bool IPCFuzzController::ObserveIPCMessage(mozilla::ipc::NodeChannel* channel,
// We can also use this message as the base template for other messages
if (!this->sampleHeader.initLengthUninitialized(
sizeof(IPC::Message::Header))) {
MOZ_REALLY_CRASH(__LINE__);
MOZ_FUZZING_NYX_ABORT("sampleHeader.initLengthUninitialized failed\n");
}
memcpy(sampleHeader.begin(), aMessage.header(),
@ -251,19 +251,17 @@ bool IPCFuzzController::ObserveIPCMessage(mozilla::ipc::NodeChannel* channel,
Vector<char, 256, InfallibleAllocPolicy> footer;
if (!footer.initLengthUninitialized(aMessage.event_footer_size())) {
MOZ_REALLY_CRASH(__LINE__);
MOZ_FUZZING_NYX_ABORT("footer.initLengthUninitialized failed\n");
}
if (!aMessage.ReadFooter(footer.begin(), footer.length(), false)) {
MOZ_FUZZING_NYX_PRINT("ERROR: ReadFooter() failed?!\n");
MOZ_REALLY_CRASH(__LINE__);
MOZ_FUZZING_NYX_ABORT("ERROR: ReadFooter() failed?!\n");
}
UniquePtr<Event> event = Event::Deserialize(footer.begin(), footer.length());
if (!event) {
MOZ_FUZZING_NYX_PRINT("ERROR: Failed to deserialize observed message?!\n");
MOZ_REALLY_CRASH(__LINE__);
MOZ_FUZZING_NYX_ABORT("ERROR: Failed to deserialize observed message?!\n");
}
if (event->type() == Event::kUserMessage) {
@ -492,8 +490,7 @@ void IPCFuzzController::StartFuzzing(mozilla::ipc::NodeChannel* channel,
NS_NewNamedThread("IPCFuzzLoop", getter_AddRefs(newThread), runnable);
if (NS_FAILED(rv)) {
MOZ_FUZZING_NYX_PRINT("ERROR: [StartFuzzing] NS_NewNamedThread failed?!\n");
MOZ_REALLY_CRASH(__LINE__);
MOZ_FUZZING_NYX_ABORT("ERROR: [StartFuzzing] NS_NewNamedThread failed?!\n");
}
#endif
}
@ -517,8 +514,7 @@ NS_IMETHODIMP IPCFuzzController::IPCFuzzLoop::Run() {
// must either be observed to update the sequence numbers, or the packet
// must be dropped already.
if (!IPCFuzzController::instance().haveTargetNodeName) {
MOZ_FUZZING_NYX_PRINT("ERROR: I don't have the target NodeName?!\n");
MOZ_REALLY_CRASH(__LINE__);
MOZ_FUZZING_NYX_ABORT("ERROR: I don't have the target NodeName?!\n");
}
{

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

@ -177,6 +177,8 @@ void Nyx::release(uint32_t iterations) {
_exit(1);
}
MOZ_FUZZING_NYX_DEBUG("[DEBUG] Nyx::release() called.\n");
nyx_release(iterations);
}