Skip to content

Commit

Permalink
Assert the GVL is held when performing various string functions.
Browse files Browse the repository at this point in the history
This is being done to debug issues in the `zlib` extension.

[Feature #20877]
  • Loading branch information
ioquatix committed Nov 7, 2024
1 parent 342455e commit 914f037
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17839,6 +17839,7 @@ string.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
string.$(OBJEXT): $(top_srcdir)/internal/serial.h
string.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
string.$(OBJEXT): $(top_srcdir)/internal/string.h
string.$(OBJEXT): $(top_srcdir)/internal/thread.h
string.$(OBJEXT): $(top_srcdir)/internal/transcode.h
string.$(OBJEXT): $(top_srcdir)/internal/variable.h
string.$(OBJEXT): $(top_srcdir)/internal/vm.h
Expand Down
5 changes: 5 additions & 0 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "internal/re.h"
#include "internal/sanitizers.h"
#include "internal/string.h"
#include "internal/thread.h"
#include "internal/transcode.h"
#include "probes.h"
#include "ruby/encoding.h"
Expand Down Expand Up @@ -2660,6 +2661,8 @@ rb_str_modify(VALUE str)
void
rb_str_modify_expand(VALUE str, long expand)
{
RUBY_ASSERT(ruby_thread_has_gvl_p());

int termlen = TERM_LEN(str);
long len = RSTRING_LEN(str);

Expand Down Expand Up @@ -3264,6 +3267,8 @@ rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg)
void
rb_str_set_len(VALUE str, long len)
{
RUBY_ASSERT(ruby_thread_has_gvl_p());

long capa;
const int termlen = TERM_LEN(str);

Expand Down

0 comments on commit 914f037

Please sign in to comment.