mattn/mruby-require

Issues with mruby 3.2.0

HellRok opened this issue · 1 comments

Hi,

I've found an issue with mruby 3.2.0.

Given these two files:

entry.rb

$:.unshift '.'

require 'zip'

and zip.rb

a = [1,2,3]
b = [:a, :b, :c]

p a.zip(b)

I am getting the error:

trace (most recent call last):
        [10] (unknown):0
        [9] (unknown):0:in require
        [8] /home/sean/Syncthing/code/c++/taylor/zip.rb:4
        [7] /home/sean/Syncthing/code/c++/taylor/zip.rb:4:in zip
        [6] /home/sean/Syncthing/code/c++/taylor/zip.rb:4:in each
        [5] /home/sean/Syncthing/code/c++/taylor/zip.rb:4:in zip
        [4] /home/sean/Syncthing/code/c++/taylor/zip.rb:4:in each
        [3] /home/sean/Syncthing/code/c++/taylor/zip.rb:4:in zip
        [2] /home/sean/Syncthing/code/c++/taylor/zip.rb:4:in next
        [1] /home/sean/Syncthing/code/c++/taylor/zip.rb:4:in next_values
/home/sean/Syncthing/code/c++/taylor/zip.rb:4:in resume: can't cross C function boundary (FiberError)

It works as expected with mruby 3.1.0

Please let me know if you require any more information

mruby originally raised a FiberError exception if a C function method was on the call stack when switching fibers.

The Fiber#resume method, which was previously overlooked, is now strictly checked in mruby 3.2.

See also:

As far as I can see from the call stack presented, it seems to be calling Fiber#resume from the #next_values method deep in the Kernel#require method implemented in C.

Nevertheless, I think there is a demand to use Fiber#resume via Kernel#require, so I will consider supporting it.
However, since it requires using a non-standard procedure that is hard to understand, I don't know if it will be accepted by the owner of this repository.

At any rate, I would like to send a pull request to this repository at some point.