From e85de00a3065461f6fac466276d915b809f40c7c Mon Sep 17 00:00:00 2001 From: Xuanzhong Wei Date: Tue, 3 Oct 2017 23:57:18 +0900 Subject: fix GC issue on rb_global_variable array We need to add the array to ruby's global_list right after created it; otherwise it probably gets GCed. --- ext/unicorn_http/unicorn_http.rl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl index 6fc3498..357440b 100644 --- a/ext/unicorn_http/unicorn_http.rl +++ b/ext/unicorn_http/unicorn_http.rl @@ -921,6 +921,7 @@ void Init_unicorn_http(void) VALUE mUnicorn, cHttpParser; mark_ary = rb_ary_new(); + rb_global_variable(&mark_ary); mUnicorn = rb_define_module("Unicorn"); cHttpParser = rb_define_class_under(mUnicorn, "HttpParser", rb_cObject); eHttpParserError = @@ -976,7 +977,6 @@ void Init_unicorn_http(void) init_unicorn_httpdate(mark_ary); OBJ_FREEZE(mark_ary); - rb_global_variable(&mark_ary); #ifndef HAVE_RB_HASH_CLEAR id_clear = rb_intern("clear"); -- cgit v1.2.3-24-ge0c7