зеркало из https://github.com/github/ruby.git
* gc.c (rb_objspace_call_finalizer): use rb_typeddata_is_kind_of() for
type check to get rid of a double free when main Thread has singleton class. [ruby-core:36741] [Bug #4828] * thread.c (rb_obj_is_mutex): add a new utility function. * vm.c (rb_obj_is_thread): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
50a058b6be
Коммит
1fdbe0f437
|
@ -1,3 +1,11 @@
|
|||
Thu Jun 9 23:34:01 2011 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
|
||||
|
||||
* gc.c (rb_objspace_call_finalizer): use rb_typeddata_is_kind_of() for
|
||||
type check to get rid of a double free when main Thread has singleton
|
||||
class. [ruby-core:36741] [Bug #4828]
|
||||
* thread.c (rb_obj_is_mutex): add a new utility function.
|
||||
* vm.c (rb_obj_is_thread): ditto.
|
||||
|
||||
Thu Jun 9 22:53:49 2011 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
|
||||
|
||||
* test/ruby/test_thread.rb (TestThread#test_kill_thread_subclass):
|
||||
|
|
2
gc.c
2
gc.c
|
@ -3005,7 +3005,7 @@ rb_objspace_call_finalizer(rb_objspace_t *objspace)
|
|||
while (p < pend) {
|
||||
if (BUILTIN_TYPE(p) == T_DATA &&
|
||||
DATA_PTR(p) && RANY(p)->as.data.dfree &&
|
||||
RANY(p)->as.basic.klass != rb_cThread && RANY(p)->as.basic.klass != rb_cMutex) {
|
||||
!rb_obj_is_thread((VALUE)p) && !rb_obj_is_mutex((VALUE)p) ) {
|
||||
p->as.free.flags = 0;
|
||||
if (RTYPEDDATA_P(p)) {
|
||||
RDATA(p)->dfree = RANY(p)->as.typeddata.type->function.dfree;
|
||||
|
|
|
@ -27,6 +27,9 @@ struct rb_classext_struct {
|
|||
|
||||
VALUE rb_big_uminus(VALUE x);
|
||||
|
||||
VALUE rb_obj_is_thread(VALUE obj);
|
||||
VALUE rb_obj_is_mutex(VALUE obj);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#if 0
|
||||
{ /* satisfy cc-mode */
|
||||
|
|
11
thread.c
11
thread.c
|
@ -3350,6 +3350,17 @@ static const rb_data_type_t mutex_data_type = {
|
|||
{mutex_mark, mutex_free, mutex_memsize,},
|
||||
};
|
||||
|
||||
VALUE
|
||||
rb_obj_is_mutex(VALUE obj)
|
||||
{
|
||||
if (rb_typeddata_is_kind_of(obj, &mutex_data_type)) {
|
||||
return Qtrue;
|
||||
}
|
||||
else {
|
||||
return Qfalse;
|
||||
}
|
||||
}
|
||||
|
||||
static VALUE
|
||||
mutex_alloc(VALUE klass)
|
||||
{
|
||||
|
|
11
vm.c
11
vm.c
|
@ -1780,6 +1780,17 @@ const rb_data_type_t ruby_thread_data_type = {
|
|||
},
|
||||
};
|
||||
|
||||
VALUE
|
||||
rb_obj_is_thread(VALUE obj)
|
||||
{
|
||||
if (rb_typeddata_is_kind_of(obj, &thread_data_type)) {
|
||||
return Qtrue;
|
||||
}
|
||||
else {
|
||||
return Qfalse;
|
||||
}
|
||||
}
|
||||
|
||||
static VALUE
|
||||
thread_alloc(VALUE klass)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче