Skip to content

Commit 5fe259e

Browse files
committed
PG::Result: Initialize all caches before freeze
Multiple Ractor instances could otherwise initialize them simultanly, leading to data races.
1 parent c75ed8d commit 5fe259e

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

ext/pg_result.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ static VALUE sym_symbol, sym_string, sym_static_symbol;
1212
static VALUE pgresult_type_map_set( VALUE, VALUE );
1313
static t_pg_result *pgresult_get_this( VALUE );
1414
static t_pg_result *pgresult_get_this_safe( VALUE );
15+
static void ensure_init_for_tuple(VALUE self);
1516

1617
#if defined(HAVE_PQRESULTMEMORYSIZE)
1718

@@ -396,6 +397,7 @@ pg_result_freeze(VALUE self)
396397
{
397398
t_pg_result *this = pgresult_get_this(self);
398399

400+
ensure_init_for_tuple(self);
399401
RB_OBJ_WRITE(self, &this->connection, Qnil);
400402
return rb_call_super(0, NULL);
401403
}

0 commit comments

Comments
 (0)