Skip to content

Commit

Permalink
Add a crash condition if on _copy_on_write the backing reference coun…
Browse files Browse the repository at this point in the history
…t is 0.
  • Loading branch information
Ivorforce committed Dec 21, 2024
1 parent 89001f9 commit 75b7a03
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/templates/cowdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ typename CowData<T>::USize CowData<T>::_copy_on_write() {
SafeNumeric<USize> *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();
Expand Down

0 comments on commit 75b7a03

Please sign in to comment.