ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:102637] [Ruby master Bug#17643] Ruby 3 embedded - no GC methods?
       [not found] <redmine.issue-17643.20210219050440.91@ruby-lang.org>
@ 2021-02-27  8:54 ` cfis
  2021-03-08  5:37 ` [ruby-core:102769] " nobu
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: cfis @ 2021-02-27  8:54 UTC (permalink / raw)
  To: ruby-core

Issue #17643 has been updated by cfis (Charlie Savage).


Just followin up. Nobu any thoughts?

----------------------------------------
Bug #17643: Ruby 3 embedded - no GC methods?
https://bugs.ruby-lang.org/issues/17643#change-90629

* Author: cfis (Charlie Savage)
* Status: Assigned
* 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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:102769] [Ruby master Bug#17643] Ruby 3 embedded - no GC methods?
       [not found] <redmine.issue-17643.20210219050440.91@ruby-lang.org>
  2021-02-27  8:54 ` [ruby-core:102637] [Ruby master Bug#17643] Ruby 3 embedded - no GC methods? cfis
@ 2021-03-08  5:37 ` nobu
  2021-04-02  8:39 ` [ruby-core:103172] " cfis
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: nobu @ 2021-03-08  5:37 UTC (permalink / raw)
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:103172] [Ruby master Bug#17643] Ruby 3 embedded - no GC methods?
       [not found] <redmine.issue-17643.20210219050440.91@ruby-lang.org>
  2021-02-27  8:54 ` [ruby-core:102637] [Ruby master Bug#17643] Ruby 3 embedded - no GC methods? cfis
  2021-03-08  5:37 ` [ruby-core:102769] " nobu
@ 2021-04-02  8:39 ` cfis
  2021-04-02  8:41 ` [ruby-core:103173] " cfis
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: cfis @ 2021-04-02  8:39 UTC (permalink / raw)
  To: ruby-core

Issue #17643 has been updated by cfis (Charlie Savage).


@nobu - Sorry that I missed your feedback.

I updated the code to call ruby_options, but that just hangs the interpreter. It thinks it is going to run a ruby script, but that is not correct. I have attached a screenshot of the call stack.

What I want to do is initialize the interpreter so I can later run code in it. As part of the initialization I'd like to set GC.stress to true.

I updated the embedding code to look like this (copied from Ruby's main function):

```c
    int argc = 0;
    char* argv = nullptr;
    char** pArgv = &argv;

    ruby_sysinit(&argc, &pArgv);
    {
      RUBY_INIT_STACK;
      ruby_init();
      ruby_run_node(ruby_options(argc, pArgv));
    }

    initialized__ = true; // <----- this is never called

```

That doesn't work. Could you point me in the direction of what does work? Thanks!


----------------------------------------
Bug #17643: Ruby 3 embedded - no GC methods?
https://bugs.ruby-lang.org/issues/17643#change-91245

* 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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:103173] [Ruby master Bug#17643] Ruby 3 embedded - no GC methods?
       [not found] <redmine.issue-17643.20210219050440.91@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2021-04-02  8:39 ` [ruby-core:103172] " cfis
@ 2021-04-02  8:41 ` cfis
  2021-08-21  1:54 ` [ruby-core:105037] " nobu (Nobuyoshi Nakada)
  2021-08-21  6:27 ` [ruby-core:105038] " cfis (Charlie Savage)
  5 siblings, 0 replies; 6+ messages in thread
From: cfis @ 2021-04-02  8:41 UTC (permalink / raw)
  To: ruby-core

Issue #17643 has been updated by cfis (Charlie Savage).

File Screenshot 2021-04-02 013926.png added

Screenshot

----------------------------------------
Bug #17643: Ruby 3 embedded - no GC methods?
https://bugs.ruby-lang.org/issues/17643#change-91248

* 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.

---Files--------------------------------
Screenshot 2021-04-02 013926.png (194 KB)
Screenshot 2021-04-02 013926.png (194 KB)
Screenshot 2021-04-02 013926.png (194 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:105037] [Ruby master Bug#17643] Ruby 3 embedded - no GC methods?
       [not found] <redmine.issue-17643.20210219050440.91@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2021-04-02  8:41 ` [ruby-core:103173] " cfis
@ 2021-08-21  1:54 ` nobu (Nobuyoshi Nakada)
  2021-08-21  6:27 ` [ruby-core:105038] " cfis (Charlie Savage)
  5 siblings, 0 replies; 6+ messages in thread
From: nobu (Nobuyoshi Nakada) @ 2021-08-21  1:54 UTC (permalink / raw)
  To: ruby-core

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


No arguments means reading the script from stdin.
You need to give a script name or an `-e` option.

----------------------------------------
Bug #17643: Ruby 3 embedded - no GC methods?
https://bugs.ruby-lang.org/issues/17643#change-93446

* 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.

---Files--------------------------------
Screenshot 2021-04-02 013926.png (194 KB)
Screenshot 2021-04-02 013926.png (194 KB)
Screenshot 2021-04-02 013926.png (194 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:105038] [Ruby master Bug#17643] Ruby 3 embedded - no GC methods?
       [not found] <redmine.issue-17643.20210219050440.91@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2021-08-21  1:54 ` [ruby-core:105037] " nobu (Nobuyoshi Nakada)
@ 2021-08-21  6:27 ` cfis (Charlie Savage)
  5 siblings, 0 replies; 6+ messages in thread
From: cfis (Charlie Savage) @ 2021-08-21  6:27 UTC (permalink / raw)
  To: ruby-core

Issue #17643 has been updated by cfis (Charlie Savage).


I don't want to do either of those things. Instead I would like to embed Ruby into a C++ program and then use it run tests.

Specifically, this is for Rice. The embed Ruby code:

https://github.com/jasonroelofs/rice/blob/master/test/embed_ruby.cpp

Then tests, for example:

https://github.com/jasonroelofs/rice/blob/master/test/test_Array.cpp

The reason I'd like to have access to the GC methods is to enable GC stress. That helps verify that Rice is correctly correctly managing memory when integrating with the interpreter.

This used to work fine in Ruby 2.x but not 3.x. I believe this is a regression and should be fixed.

----------------------------------------
Bug #17643: Ruby 3 embedded - no GC methods?
https://bugs.ruby-lang.org/issues/17643#change-93447

* 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.

---Files--------------------------------
Screenshot 2021-04-02 013926.png (194 KB)
Screenshot 2021-04-02 013926.png (194 KB)
Screenshot 2021-04-02 013926.png (194 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-08-21  6:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-17643.20210219050440.91@ruby-lang.org>
2021-02-27  8:54 ` [ruby-core:102637] [Ruby master Bug#17643] Ruby 3 embedded - no GC methods? cfis
2021-03-08  5:37 ` [ruby-core:102769] " nobu
2021-04-02  8:39 ` [ruby-core:103172] " cfis
2021-04-02  8:41 ` [ruby-core:103173] " cfis
2021-08-21  1:54 ` [ruby-core:105037] " nobu (Nobuyoshi Nakada)
2021-08-21  6:27 ` [ruby-core:105038] " cfis (Charlie Savage)

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 read-only IMAP folder(s) and NNTP newsgroup(s).