#2201·hermes

tryGetMutableBuffer() segfaults after another external ArrayBuffer gets a property

Author: mrousavyCreated Sep 25, 2026Updated Sep 25, 2026

jsi::ArrayBuffer::tryGetMutableBuffer() segfaults once another external ArrayBuffer has an extra property, e.g. from setExternalMemoryPressure:

cpp
struct Buf : jsi::MutableBuffer {
  uint8_t bytes[8]{};
  size_t size() const override { return 8; }
  uint8_t* data() override { return bytes; }
};

auto rt = facebook::hermes::makeHermesRuntime();
jsi::ArrayBuffer a(*rt, std::make_shared<Buf>());
a.setExternalMemoryPressure(*rt, 8);
jsi::ArrayBuffer b(*rt, std::make_shared<Buf>());
b.tryGetMutableBuffer(*rt); // segfault in JSArrayBuffer::getExternalDataContext

Happens on static_h (ced24915f) and hermes-v260318099.0.3 (macOS arm64, release).

My guess: a's transition takes the property map from the shared hidden class, so the lookup in getExternalDataContext has to rebuild it. That allocates inside its NoAllocScope and makes handles, and HermesRuntimeImpl::tryGetMutableBuffer never opens a GCScope. With asserts on you get No allocs allowed right now instead, even from inside a HostFunction.

A GCScope in tryGetMutableBuffer plus moving the NoAllocScope below the lookup would probably fix it.