[ruby-core:102769] [Ruby master Bug#17643] Ruby 3 embedded - no GC methods?
From:
nobu@...
Date:
2021-03-08 05:37:59 UTC
List:
ruby-core #102769
Issue #17643 has been updated by nobu (Nobuyoshi Nakada).
Status changed from Assigned to Rejected
You don't call `ruby_process_options`.
And the `argv` made in this part is wrong.
> ```c
> int argc = 0;
> char* argv = (char*)malloc(1);
> argv[0] = 0;
> char** pArgv = &argv;
> ```
----------------------------------------
Bug #17643: Ruby 3 embedded - no GC methods?
https://bugs.ruby-lang.org/issues/17643#change-90789
* Author: cfis (Charlie Savage)
* Status: Rejected
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x64-mingw32]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
The following code works on Ruby 2.x, but not on Ruby 3.0.0.
``` c
// Initialize Ruby VM
int argc = 0;
char* argv = (char*)malloc(1);
argv[0] = 0;
char** pArgv = &argv;
ruby_sysinit(&argc, &pArgv);
ruby_init();
ruby_init_loadpath();
// Try to call GC.start
int state;
VALUE result = rb_eval_string_protect("GC.start", &state);
VALUE err = rb_errinfo();
VALUE rubyMessage = rb_funcall(err, rb_intern("message"), 0);
char* message = RSTRING_PTR(rubyMessage);
message is "undefined method `start' for GC:Module"
```
This is true for all the GC methods (stop, stress, etc). Note if you create a Ruby script that contains GC.start and run it using the Ruby interpreter all is well.
Is there some new special way Ruby 3 needs to be embedded?
Note I tested this on mingw, MSVC and gcc (Fedora). All the same. Like I said above, this code works fine on Ruby 2.7 and earlier.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>