diff --git a/core/templates/cowdata.h b/core/templates/cowdata.h index dbbb1e6b540f..3e463a81efca 100644 --- a/core/templates/cowdata.h +++ b/core/templates/cowdata.h @@ -296,6 +296,8 @@ typename CowData::USize CowData::_copy_on_write() { SafeNumeric *refc = _get_refcount(); USize rc = refc->get(); + CRASH_COND_MSG(rc == 0, "Reference count was 0 at the time of fork."); + if (unlikely(rc > 1)) { /* in use by more than me */ USize current_size = *_get_size();