Skip to content

Instantly share code, notes, and snippets.

@bendk
Created April 10, 2024 15:13
Show Gist options
  • Save bendk/effb3dd0c52a780f980816be36537f65 to your computer and use it in GitHub Desktop.
Save bendk/effb3dd0c52a780f980816be36537f65 to your computer and use it in GitHub Desktop.
diff --git a/toolkit/components/uniffi-js/UniFFIPointer.cpp b/toolkit/components/uniffi-js/UniFFIPointer.cpp
index b77ef853957a7..edc6f69d90c28 100644
--- a/toolkit/components/uniffi-js/UniFFIPointer.cpp
+++ b/toolkit/components/uniffi-js/UniFFIPointer.cpp
@@ -81,6 +82,11 @@ void UniFFIPointer::Write(const ArrayBuffer& aArrayBuff, uint32_t aPosition,
// in Rust and Read(), a u64 is read as BigEndian and then converted to
// a pointer we do the reverse here
const auto& data_ptr = aData.Subspan(aPosition, 8);
+ // The hazard checker assumes all calls to a function pointer may result in a GC call and
+ // `ClonePtr` calls mType->clone. However, we know that mtype->clone won't make a GC call
+ // since it's essentially just a call to Rust's `Arc::clone()`. Use AutoSuppressGCAnalysis
+ // to tell the hazard checker to ignore the call.
+ JS::AutoSuppressGCAnalysis suppress;
mozilla::BigEndian::writeUint64(data_ptr.Elements(),
(uint64_t)ClonePtr());
return true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment