mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Make imemo_alloc writebarrier-unprotected
imemo_alloc provides a memory buffer whose contents are marked by GC. C code can access imemo_alloc buffer freely, so imemo_alloc must be considered writebarrier-unprotected. But T_IMEMO is writebarrier- protected by default, which caused a GC bug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
872b9ec896
commit
fdb771d82d
2 changed files with 4 additions and 0 deletions
1
gc.c
1
gc.c
|
@ -8118,6 +8118,7 @@ rb_alloc_tmp_buffer_with_count(volatile VALUE *store, size_t size, size_t cnt)
|
|||
void *ptr;
|
||||
|
||||
s = rb_imemo_new(imemo_alloc, 0, 0, 0, 0);
|
||||
rb_gc_writebarrier_unprotect(s);
|
||||
ptr = ruby_xmalloc0(size);
|
||||
a = (rb_imemo_alloc_t*)s;
|
||||
a->ptr = (VALUE*)ptr;
|
||||
|
|
3
parse.y
3
parse.y
|
@ -11538,6 +11538,7 @@ rb_parser_malloc(struct parser_params *parser, size_t size)
|
|||
size_t cnt = HEAPCNT(1, size);
|
||||
rb_imemo_alloc_t *n = NEWHEAP();
|
||||
void *ptr = xmalloc(size);
|
||||
rb_gc_writebarrier_unprotect((VALUE)n);
|
||||
|
||||
return ADD2HEAP(n, cnt, ptr);
|
||||
}
|
||||
|
@ -11548,6 +11549,7 @@ rb_parser_calloc(struct parser_params *parser, size_t nelem, size_t size)
|
|||
size_t cnt = HEAPCNT(nelem, size);
|
||||
rb_imemo_alloc_t *n = NEWHEAP();
|
||||
void *ptr = xcalloc(nelem, size);
|
||||
rb_gc_writebarrier_unprotect((VALUE)n);
|
||||
|
||||
return ADD2HEAP(n, cnt, ptr);
|
||||
}
|
||||
|
@ -11569,6 +11571,7 @@ rb_parser_realloc(struct parser_params *parser, void *ptr, size_t size)
|
|||
}
|
||||
n = NEWHEAP();
|
||||
ptr = xrealloc(ptr, size);
|
||||
rb_gc_writebarrier_unprotect((VALUE)n);
|
||||
return ADD2HEAP(n, cnt, ptr);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue