Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix race condition in setting up RString data

We only set the type in the end if everything is ready. Before we had a
race condition where type_ was already set to cRString, but the data
wasn't allocated yet. By setting up a memory barrier and setting the
type after that, we make sure all the data is initialized properly.
  • Loading branch information...
commit 5f13e5f8d759d93500c55316da0b555d81b8a91f 1 parent d1e0eec
@dbussink dbussink authored
Showing with 2 additions and 1 deletion.
  1. +2 −1  vm/capi/string.cpp
View
3  vm/capi/string.cpp
@@ -109,7 +109,6 @@ namespace rubinius {
unset = type_ != cRString;
if(unset) {
- type_ = cRString;
string->unshare(env->state());
@@ -123,6 +122,8 @@ namespace rubinius {
} else {
env->check_tracked_handle(this, false);
}
+ atomic::memory_barrier();
+ type_ = cRString;
}
env->shared().capi_ds_lock().unlock();
Please sign in to comment.
Something went wrong with that request. Please try again.