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

ruby-changes:58528

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Fri, 1 Nov 2019 16:59:01 +0900 (JST)
Subject: [ruby-changes:58528] fb495b2928 (master): rb_aligned_malloc can return NULL

https://git.ruby-lang.org/ruby.git/commit/?id=fb495b2928

From fb495b2928545e44cc9859f7cc743032d92ca9ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Fri, 1 Nov 2019 14:33:44 +0900
Subject: rb_aligned_malloc can return NULL

Looking at gc.c, rb_aligned_malloc contains `return NULL;` so it
has to be taken care of.  Note however that posix_memalign(3posix)
does _not_ set errno.

diff --git a/transient_heap.c b/transient_heap.c
index 6cdd342..6e9cf64 100644
--- a/transient_heap.c
+++ b/transient_heap.c
@@ -294,6 +294,9 @@ transient_heap_block_alloc(struct transient_heap* theap) https://github.com/ruby/ruby/blob/trunk/transient_heap.c#L294
 #else
     if (theap->arena == NULL) {
         theap->arena = rb_aligned_malloc(TRANSIENT_HEAP_BLOCK_SIZE, TRANSIENT_HEAP_TOTAL_SIZE);
+        if (theap->arena == NULL) {
+             rb_bug("transient_heap_block_alloc: failed\n");
+        }
     }
 
     TH_ASSERT(theap->arena_index < TRANSIENT_HEAP_BLOCK_NUM);
-- 
cgit v0.10.2


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

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