From 3b82ba8433a10d74a8f7eb195570e0129c2845be Mon Sep 17 00:00:00 2001 From: "Christian Holler (:decoder)" Date: Tue, 14 Mar 2023 07:50:36 +0000 Subject: [PATCH] Bug 1821008 - Add nyx abort macro and more debug messages. r=truber,glandium Differential Revision: https://phabricator.services.mozilla.com/D171979 --- mfbt/Fuzzing.h | 6 ++++++ tools/fuzzing/ipc/IPCFuzzController.cpp | 18 +++++++----------- tools/fuzzing/nyx/Nyx.cpp | 2 ++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/mfbt/Fuzzing.h b/mfbt/Fuzzing.h index dae79480bd3d..74354366152e 100644 --- a/mfbt/Fuzzing.h +++ b/mfbt/Fuzzing.h @@ -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) diff --git a/tools/fuzzing/ipc/IPCFuzzController.cpp b/tools/fuzzing/ipc/IPCFuzzController.cpp index 522da16d2327..97f8e76a7500 100644 --- a/tools/fuzzing/ipc/IPCFuzzController.cpp +++ b/tools/fuzzing/ipc/IPCFuzzController.cpp @@ -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 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::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"); } { diff --git a/tools/fuzzing/nyx/Nyx.cpp b/tools/fuzzing/nyx/Nyx.cpp index b17278b2ad0d..5c48d3342b61 100644 --- a/tools/fuzzing/nyx/Nyx.cpp +++ b/tools/fuzzing/nyx/Nyx.cpp @@ -177,6 +177,8 @@ void Nyx::release(uint32_t iterations) { _exit(1); } + MOZ_FUZZING_NYX_DEBUG("[DEBUG] Nyx::release() called.\n"); + nyx_release(iterations); }