aboutsummaryrefslogtreecommitdiffstats
path: root/thread_pthread.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-08 07:27:24 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-08 07:27:24 +0000
commit875e2ad5b9673620425fd0047d8a60bfb000fc69 (patch)
treefccf7a5a80e337ef710f0516b5f59a0bddc7f2ce /thread_pthread.c
parentaf0fbdebace2372dab1924f8506117bd7e5a0e89 (diff)
downloadruby-875e2ad5b9673620425fd0047d8a60bfb000fc69.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_pthread.c')
-rw-r--r--thread_pthread.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index 722ce44487..d2ce8fc50b 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -1767,14 +1767,12 @@ mjit_worker(void *arg)
/* Launch MJIT thread. Returns FALSE if it fails to create thread. */
int
-rb_thread_create_mjit_thread(void (*child_hook)(void), void (*worker_func)(void))
+rb_thread_create_mjit_thread(void (*worker_func)(void))
{
pthread_attr_t attr;
pthread_t worker_pid;
int ret = FALSE;
- pthread_atfork(NULL, NULL, child_hook);
-
if (pthread_attr_init(&attr) != 0) return ret;
/* jit_worker thread is not to be joined */