Actions
Bug #20981
closedrb_undefine_finalizer is missing
Description
Merry Christmas!
I encountered an error like "dyld[89037]: missing symbol called" in an extension which usesrb_undefine_finalizer
in Ruby 3.4.1. It works fine in Ruby 3.3.6.
The function defined in ruby/include/ruby/internal/gc.h but seems removed from ruby/gc.c. Could you consider restore the implementation or remove the function from gc.h
?
Reproducible code:
extconf.rb¶
require "mkmf"
create_makefile "undefine_finalizer_bug"
undefine_finalizer_bug.c¶
#include<ruby.h>
static VALUE s_undefine_finalizer(VALUE self) {
rb_undefine_finalizer(self);
return Qnil;
}
void Init_undefine_finalizer_bug(void) {
VALUE klass = rb_define_class("UndefineFinalizerBug", rb_cObject);
rb_define_singleton_method(klass, "undefine_finalizer", s_undefine_finalizer, 0);
}
undefine-finalizer-bug.rb¶
require "undefine_finalizer_bug.so"
finalizer = proc {
puts "Finalizer called"
}
ObjectSpace.define_finalizer(UndefineFinalizerBug, finalizer)
UndefineFinalizerBug.new
UndefineFinalizerBug.undefine_finalizer
GC.start
Running¶
Ruby 3.4.1¶
% ruby ./extconf.rb && make && ruby -v -I. ./undefine-finalizer-bug.rb
creating Makefile
linking shared-object undefine_finalizer_bug.bundle
ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [arm64-darwin24]
dyld[2436]: missing symbol called
[1] 2436 abort ruby -v -I. ./undefine-finalizer-bug.rb
Ruby 3.3.6¶
% chruby-exec 3.3.6 -- ruby ./extconf.rb && make && chruby-exec 3.3.6 -- ruby -v -I. ./undefine-finalizer-bug.rb
creating Makefile
linking shared-object undefine_finalizer_bug.bundle
ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [arm64-darwin24]
Thank you.
Updated by nobu (Nobuyoshi Nakada) 1 day ago
Hmmm, these symbols disappeared.
$ comm -23 <(nm -PUg 3.3.6/lib/libruby.dylib | cut -d' ' -f1) <(nm -PUg 3.4.1/lib/libruby.dylib | cut -d' ' -f1)
_rb_ary_memsize
_rb_ast_add_mark_object
_rb_ast_delete_mark_object
_rb_ast_mark
_rb_ast_set_tokens
_rb_ast_tokens
_rb_ast_update_references
_rb_autoload
_rb_file_s_birthtime
_rb_fstring
_rb_gc_force_recycle
_rb_gc_verify_internal_consistency
_rb_generic_ivar_memsize
_rb_grantpt
_rb_hash_tbl_raw
_rb_io_memsize
_rb_newobj
_rb_newobj_of
_rb_objspace_data_type_memsize
_rb_objspace_each_objects_without_setup
_rb_objspace_markable_object_p
_rb_objspace_marked_object_p
_rb_parser_calloc
_rb_parser_free
_rb_parser_malloc
_rb_parser_realloc
_rb_ruby_parser_compile_string
_rb_st_init_existing_table_with_size
_rb_st_replace
_rb_str_locktmp_ensure
_rb_str_make_embedded
_rb_str_memsize
_rb_str_reembeddable_p
_rb_str_size_as_embedded
_rb_str_tmp_frozen_no_embed_acquire
_rb_str_upto_each
_rb_str_upto_endless_each
_rb_undefine_finalizer
rb_gc_force_recycle
is now defined as static inline
in include/ruby/internal/gc.h.
Probably only rb_undefine_finalizer
is problematic?
Updated by nobu (Nobuyoshi Nakada) 1 day ago
- Backport changed from 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN to 3.1: DONTNEED, 3.2: DONTNEED, 3.3: DONTNEED, 3.4: REQUIRED
Updated by nobu (Nobuyoshi Nakada) 1 day ago
- Status changed from Open to Closed
Applied in changeset git|7df5d65eac86940619f87da7e70bc0911097ae2f.
[Bug #20981] Bring back rb_undefine_finalizer
Updated by KitaitiMakoto (真 北市) 1 day ago
Thank you! I confirmed my code works fine in Ruby master
branch.
Actions
Like0
Like0Like0Like1Like0