Open csabahenk opened 3 years ago
Same issue on our side. Everything work perfectly until we migrate to Ruby 3.0.2. Here is the top of our trace
/opt/hostedtoolcache/Ruby/3.0.2/x64/lib/ruby/gems/3.0.0/gems/citrus-3.0.2/lib/citrus.rb:1286: [BUG] Segmentation fault at 0x000055892ffad208
ruby 3.0.2p***7 (2021-07-07 revision 0db68f0233) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0172 p:---- s:***35 e:00***34 CFUNC :slice!
c:0171 p:0063 s:***29 e:00***28 METHOD /opt/hostedtoolcache/Ruby/3.0.2/x64/lib/ruby/gems/3.0.0/gems/citrus-3.0.2/lib/citrus.rb:1286 [FINISH]
c:0170 p:---- s:***20 e:00***19 CFUNC :new
c:0169 p:0139 s:***13 e:00***12 METHOD /opt/hostedtoolcache/Ruby/3.0.2/x64/lib/ruby/gems/3.0.0/gems/citrus-3.0.2/lib/citrus.rb:1470
c:0168 p:0011 s:0998 e:000997 METHOD /opt/hostedtoolcache/Ruby/3.0.2/x64/lib/ruby/gems/3.0.0/gems/citrus-3.0.2/lib/citrus.rb:1330
c:0167 p:0003 s:0993 e:000992 METHOD /opt/hostedtoolcache/Ruby/3.0.2/x64/lib/ruby/gems/3.0.0/gems/citrus-3.0.2/lib/citrus.rb:1336
c:0166 p:0062 s:0988 e:000983 BLOCK (eval):4 [FINISH]
As said above, it does not seem to happen on every run. Issue happens on macOS & Ubuntu.
Minimal reproduction is available at https://github.com/vhiairrassary/citrus-issue-60. To reproduce the issue, I just use the calc
grammar from citrus and run it indefinitely until it crashes. Full stack trace is available in the repository README.md file.
require 'citrus'
Citrus.load 'calc'
loop do
puts Calc.parse('1 + 2 + 3').value
end
Please note that this is a bug in Ruby 3.0.0-3.0.2. I've reported it upstream at https://bugs.ruby-lang.org/issues/18138 and submitted a PR to fix it at https://github.com/ruby/ruby/pull/4787
In the meantime, I'll submit a PR to citrus that will work around the bug conditions.
See PR at #61
Note that the underlying issue is fixed in Ruby 3.0.3.
I get a segfault sporadically when I'm requiring toml-rb. I figured out that this happens when the toml-rb code is loading some Citrus grammars. I report this issue to Citrus as this seems to be incorrect behavior regardless the content of those grammars.
This is what toml-rb is doing:
In those cases when I bothered to check the crash data, the crash occurred when loading of array.citrus was attempted; I'll post an update if I will find it occuring in another Citrus.load call.
I'm aware of this behavior with Ruby 3.0.x; I'm not sure if it has ever occurred with Ruby 2.x, but I think it hasn't. As this happens during an invocation of a script in an interactive shell, a plausible workaround is to re-run the command, which usually succeeds.
I'm on Arch Linux x86_64, package versions:
(Unknown Packager in Arch parlance means "unofficial package").
Crash data: