From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-4.1 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 7C7721F8C6 for ; Sat, 21 Aug 2021 06:27:29 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id AF8DC120B83; Sat, 21 Aug 2021 15:26:05 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id BCB4F120B82 for ; Sat, 21 Aug 2021 15:26:03 +0900 (JST) Received: by filterdrecv-64b996ffd8-pbxcl with SMTP id filterdrecv-64b996ffd8-pbxcl-1-61209CC5-18 2021-08-21 06:27:18.000846997 +0000 UTC m=+634970.852719031 Received: from herokuapp.com (unknown) by ismtpd0165p1mdw1.sendgrid.net (SG) with ESMTP id 2k_3ccTHQi2ecylzquMNFg for ; Sat, 21 Aug 2021 06:27:17.878 +0000 (UTC) Date: Sat, 21 Aug 2021 06:27:18 +0000 (UTC) From: "cfis (Charlie Savage)" Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17643 X-Redmine-Issue-Author: cfis X-Redmine-Issue-Assignee: nobu X-Redmine-Sender: cfis X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-Redmine-MailingListIntegration-Message-Ids: 81214 X-SG-EID: =?us-ascii?Q?lzWx=2FPsuTrF5AbkX3GAVvGd6W+mfYvL=2FAznto6T0Bk9WvAGDMBdCfLC5HHQqnO?= =?us-ascii?Q?28OuwQvLYle1LCkAthS6YsZ21834annPycJxR9T?= =?us-ascii?Q?GwwGlJgfnvPR=2FGD9lQ=2FR3sGXa=2FnAEXSq9=2FYHMDL?= =?us-ascii?Q?QcpEhzJEoZAcA9u+M=2FxAvayQ=2FEX0MBYmtPs6Isr?= =?us-ascii?Q?8Vzcpbr4+5TFtOOCxm7czhTof4X03rSui4EXRyJ?= =?us-ascii?Q?CdnIWzeeXBH2EjpJauHHV48=2F5ntlqwhx0o7Kcx3?= =?us-ascii?Q?k0lkVbhqCBmRKcowUcOhw=3D=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 105038 Subject: [ruby-core:105038] [Ruby master Bug#17643] Ruby 3 embedded - no GC methods? X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "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/