unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Xuanzhong Wei <azrlew@gmail.com>
To: unicorn-public@bogomips.org
Cc: Xuanzhong Wei <azrlew@gmail.com>
Subject: [PATCH] fix GC issue on rb_global_variable array
Date: Tue,  3 Oct 2017 23:57:18 +0900	[thread overview]
Message-ID: <20171003145718.30404-1-azrlew@gmail.com> (raw)

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");
-- 
2.14.1


             reply	other threads:[~2017-10-03 14:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-03 14:57 Xuanzhong Wei [this message]
2017-10-03 17:47 ` [PATCH] fix GC issue on rb_global_variable array Eric Wong
2017-10-03 18:26   ` Xuanzhong Wei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171003145718.30404-1-azrlew@gmail.com \
    --to=azrlew@gmail.com \
    --cc=unicorn-public@bogomips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).