* [PATCH] fix GC issue on rb_global_variable array
@ 2017-10-03 14:57 Xuanzhong Wei
2017-10-03 17:47 ` Eric Wong
0 siblings, 1 reply; 3+ messages in thread
From: Xuanzhong Wei @ 2017-10-03 14:57 UTC (permalink / raw)
To: unicorn-public; +Cc: Xuanzhong Wei
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fix GC issue on rb_global_variable array
2017-10-03 14:57 [PATCH] fix GC issue on rb_global_variable array Xuanzhong Wei
@ 2017-10-03 17:47 ` Eric Wong
2017-10-03 18:26 ` Xuanzhong Wei
0 siblings, 1 reply; 3+ messages in thread
From: Eric Wong @ 2017-10-03 17:47 UTC (permalink / raw)
To: Xuanzhong Wei; +Cc: unicorn-public
Xuanzhong Wei <azrlew@gmail.com> wrote:
> 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);
Yes, the compiler should be free to drop mark_ary by here, since
it only needs its address (not the actual VALUE) and OBJ_FREEZE
only accesses the RBasic->flags field if init_unicorn_httpdate
gets inlined.
Pushed to master as e85de00a3065461f6fac466276d915b809f40c7c.
Also, created a 5.3-stable branch for 5.3.1 (to be released today)
@ git://bogomips.org/unicorn
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fix GC issue on rb_global_variable array
2017-10-03 17:47 ` Eric Wong
@ 2017-10-03 18:26 ` Xuanzhong Wei
0 siblings, 0 replies; 3+ messages in thread
From: Xuanzhong Wei @ 2017-10-03 18:26 UTC (permalink / raw)
To: e; +Cc: azrlew, unicorn-public
Really appreciate your help!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-10-03 18:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-03 14:57 [PATCH] fix GC issue on rb_global_variable array Xuanzhong Wei
2017-10-03 17:47 ` Eric Wong
2017-10-03 18:26 ` Xuanzhong Wei
unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://yhbt.net/unicorn-public
git clone --mirror http://ou63pmih66umazou.onion/unicorn-public
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V1 unicorn-public unicorn-public/ https://yhbt.net/unicorn-public \
unicorn-public@yhbt.net unicorn-public@bogomips.org mongrel-unicorn@rubyforge.org mongrel-unicorn-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
public-inbox-index unicorn-public
Example config snippet for mirrors.
Newsgroups are available over NNTP:
nntp://news.public-inbox.org/inbox.comp.lang.ruby.unicorn
nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.unicorn
note: .onion URLs require Tor: https://www.torproject.org/
code repositories for the project(s) associated with this inbox:
../../../unicorn.git
AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git