Project

General

Profile

Actions

Bug #19086

closed

Dir#entries and Dir#glob fail in stand-alone CRuby app

Added by kyonides (Edwin Acuña) about 2 years ago. Updated about 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu]
[ruby-core:110518]

Description

Whenever I call Dir.entries or Dir.glob using an app compiled against Ruby 3.0 on Ubuntu 22.04, I expect to get a list of files or directories present there. This does not happen if you are calling it from a stand-alone app like the one I attached to this bug report.

It does not matter if I call it by evaluating some C string or by depending on a rb_funcall, it will certainly fail to do anything.

First Result: the application will segfault in no time.

Second Result: if calling rb_eval_string_protect function to evaluate the string, calling Dir#entries or Dir#glob methods, you get the following output.

NoMethodError raised!
undefined method `glob' for Dir:Class

TypeError raised!
wrong argument type File (expected dir)
eval:1:in `entries'

Dir#entries treats the tmp directory that the test code had created via Dir#mkdir as a file...

I have also tried compiling the same CRuby app against Ruby 2.7 and everything works fine. I suspect that the introduction of Primitive is causing this issue. CRuby 3.0 is unable to find the context of Primitive or any default Ruby script installed on the target machine that may call Primitive at some point.

The expected result should be to be able to get both methods return all of the files and directories as it used to do in earlier versions of Ruby.


Files

main.cpp (2.12 KB) main.cpp CRuby Test Code kyonides (Edwin Acuña), 10/26/2022 07:01 PM
ruby30 output.txt (464 Bytes) ruby30 output.txt Output using rb_eval_string_protect kyonides (Edwin Acuña), 10/26/2022 07:11 PM
Actions

Also available in: Atom PDF

Like0
Like1Like0Like0