From 7db8e5b298a44ec83591fb779d4f612a43e877e8 Mon Sep 17 00:00:00 2001 From: k0kubun Date: Sat, 11 Aug 2018 14:34:05 +0000 Subject: mjit_worker.c: handle calloc failure Unlike ZALLOC, it's not automatically handled. mjit.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- mjit.c | 5 +++++ mjit_worker.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/mjit.c b/mjit.c index 4db2498a3c..2f2cfc71ed 100644 --- a/mjit.c +++ b/mjit.c @@ -291,6 +291,11 @@ mjit_add_iseq_to_process(const rb_iseq_t *iseq) return; node = create_list_node(iseq->body->jit_unit); + if (node == NULL) { + mjit_warning("failed to allocate a node to be added to unit_queue"); + return; + } + CRITICAL_SECTION_START(3, "in add_iseq_to_process"); add_to_list(node, &unit_queue); if (active_units.length >= mjit_opts.max_cache_size) { diff --git a/mjit_worker.c b/mjit_worker.c index c37bec8e29..adc96abde0 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -319,6 +319,7 @@ static struct rb_mjit_unit_node * create_list_node(struct rb_mjit_unit *unit) { struct rb_mjit_unit_node *node = (struct rb_mjit_unit_node *)calloc(1, sizeof(struct rb_mjit_unit_node)); /* To prevent GC, don't use ZALLOC */ + if (node == NULL) return NULL; node->unit = unit; return node; } @@ -1116,6 +1117,11 @@ convert_unit_to_func(struct rb_mjit_unit *unit) if ((uintptr_t)func > (uintptr_t)LAST_JIT_ISEQ_FUNC) { struct rb_mjit_unit_node *node = create_list_node(unit); + if (node == NULL) { + mjit_warning("failed to allocate a node to be added to active_units"); + return (mjit_func_t)NOT_COMPILED_JIT_ISEQ_FUNC; + } + CRITICAL_SECTION_START(3, "end of jit"); add_to_list(node, &active_units); if (unit->iseq) -- cgit v1.2.3