[前][次][番号順一覧][スレッド一覧]

ruby-changes:52096

From: k0kubun <ko1@a...>
Date: Sat, 11 Aug 2018 23:34:11 +0900 (JST)
Subject: [ruby-changes:52096] k0kubun:r64304 (trunk): mjit_worker.c: handle calloc failure

k0kubun	2018-08-11 23:34:05 +0900 (Sat, 11 Aug 2018)

  New Revision: 64304

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64304

  Log:
    mjit_worker.c: handle calloc failure
    
    Unlike ZALLOC, it's not automatically handled.
    
    mjit.c: ditto

  Modified files:
    trunk/mjit.c
    trunk/mjit_worker.c
Index: mjit_worker.c
===================================================================
--- mjit_worker.c	(revision 64303)
+++ mjit_worker.c	(revision 64304)
@@ -319,6 +319,7 @@ static struct rb_mjit_unit_node * https://github.com/ruby/ruby/blob/trunk/mjit_worker.c#L319
 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 https://github.com/ruby/ruby/blob/trunk/mjit_worker.c#L1117
 
     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)
Index: mjit.c
===================================================================
--- mjit.c	(revision 64303)
+++ mjit.c	(revision 64304)
@@ -291,6 +291,11 @@ mjit_add_iseq_to_process(const rb_iseq_t https://github.com/ruby/ruby/blob/trunk/mjit.c#L291
         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) {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]