Skip to content

Commit 6a79a06

Browse files
committed
ssl: do not call session_remove_cb during GC
As noted in the SSL_CTX_sess_set_remove_cb(3) manpage, SSL_CTX_free() will call the callback function for each session in the internal session store. We can't call the callback Proc since it may do a new object allocation which is prohibited during GC.
1 parent df37b7a commit 6a79a06

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ext/openssl/ossl_ssl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,13 @@ ossl_sslctx_session_remove_cb(SSL_CTX *ctx, SSL_SESSION *sess)
476476
void *ptr;
477477
int state = 0;
478478

479+
/*
480+
* This callback is also called for all sessions in the internal store
481+
* when SSL_CTX_free() is called.
482+
*/
483+
if (rb_during_gc())
484+
return;
485+
479486
OSSL_Debug("SSL SESSION remove callback entered");
480487

481488
if ((ptr = SSL_CTX_get_ex_data(ctx, ossl_ssl_ex_ptr_idx)) == NULL)

0 commit comments

Comments
 (0)