ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "nobu (Nobuyoshi Nakada) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "nobu (Nobuyoshi Nakada)" <noreply@ruby-lang.org>
Subject: [ruby-core:120406] [Ruby master Bug#20981] rb_undefine_finalizer is missing
Date: Wed, 25 Dec 2024 13:17:54 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-111185.20241225131754.55443@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-20981.20241225115324.55443@ruby-lang.org>

Issue #20981 has been updated by nobu (Nobuyoshi Nakada).


Hmmm, these symbols disappeared.

```console
$ 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?

----------------------------------------
Bug #20981: rb_undefine_finalizer is missing
https://bugs.ruby-lang.org/issues/20981#change-111185

* Author: KitaitiMakoto (真 北市)
* Status: Open
* ruby -v: 3.4.1
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Merry Christmas!

I encountered an error like "dyld[89037]: missing symbol called" in an extension which uses`rb_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](https://github.com/ruby/ruby/blob/v3_4_1/include/ruby/internal/gc.h#L315-L326) but seems removed from [ruby/gc.c](https://github.com/ruby/ruby/blob/v3_4_1/gc.c). Could you consider restore the implementation or remove the function from `gc.h`?

Reproducible code:

### extconf.rb ###
```ruby
require "mkmf"
create_makefile "undefine_finalizer_bug"
```


### undefine_finalizer_bug.c ###
```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 ###
```ruby
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.




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

  reply	other threads:[~2024-12-25 13:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-25 11:53 [ruby-core:120404] " KitaitiMakoto via ruby-core
2024-12-25 13:17 ` nobu (Nobuyoshi Nakada) via ruby-core [this message]
2024-12-25 13:28 ` [ruby-core:120407] " nobu (Nobuyoshi Nakada) via ruby-core
2024-12-25 14:27 ` [ruby-core:120408] " KitaitiMakoto via ruby-core
2025-02-14  1:48 ` [ruby-core:121001] " k0kubun (Takashi Kokubun) via ruby-core

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-111185.20241225131754.55443@ruby-lang.org \
    --to=ruby-core@ml.ruby-lang.org \
    --cc=noreply@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).