diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-07-08 07:27:24 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-07-08 07:27:24 +0000 |
commit | c93adfc170079a54965e939a5a4d57139cd714e1 (patch) | |
tree | fccf7a5a80e337ef710f0516b5f59a0bddc7f2ce /thread.c | |
parent | a1e589498d1b80e3bc8b3e8c5c07874afcf0cb17 (diff) | |
download | ruby-c93adfc170079a54965e939a5a4d57139cd714e1.tar.gz |
mjit: get rid of memory leak in pause+resume loop
pthread_atfork is not idempotent and repeatedly calling it
causes it to register the same hook repeatedly; leading to
unbound memory growth.
Ruby already has a (confusing-named) internal API for to call
in the forked child process: rb_thread_atfork
Call the MJIT child_after_fork hook inside that to prevent
unbound growth with the following loop:
loop do
RubyVM::MJIT.pause
RubyVM::MJIT.resume
end
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -4276,6 +4276,8 @@ terminate_atfork_i(rb_thread_t *th, const rb_thread_t *current_th) } } +/* mjit.c */ +void mjit_child_after_fork(void); void rb_thread_atfork(void) { @@ -4286,6 +4288,7 @@ rb_thread_atfork(void) /* We don't want reproduce CVE-2003-0900. */ rb_reset_random_seed(); + mjit_child_after_fork(); } static void |