From f029beffe8e86b1b6e8f27b8dcc0514b99fa8bac Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 6 May 2022 08:06:26 +0100 Subject: [PATCH] Ruby li_std_set test failure workaround Prevent GC from collecting "hello" string in testcase as workaround to prevent GC occasionally causing segfault. Issue #2115 --- .github/workflows/ci.yml | 1 - Examples/test-suite/ruby/li_std_set_runme.rb | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a03ca7459..60791155c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -167,7 +167,6 @@ jobs: VER: '2.5' - SWIGLANG: ruby VER: '2.6' - continue-on-error: true # Sometimes fails, see https://github.com/swig/swig/issues/2115 - SWIGLANG: ruby VER: '2.7' - SWIGLANG: ruby diff --git a/Examples/test-suite/ruby/li_std_set_runme.rb b/Examples/test-suite/ruby/li_std_set_runme.rb index efc163bee..455a1706e 100644 --- a/Examples/test-suite/ruby/li_std_set_runme.rb +++ b/Examples/test-suite/ruby/li_std_set_runme.rb @@ -56,11 +56,15 @@ m.value == 'c' s = LanguageSet.new s.insert([1,2]) s.insert(1) -s.insert("hello") +# There is a reference count issue that needs fixing, see https://github.com/swig/swig/issues/2115 +# Workaround is to create hello variable containing a string and use it instead of just "hello" +hello = "hello" +s.insert(hello) #s.to_a == [1,[1,2],'hello'] # sort order: s.sort {|a,b| a.hash <=> b.hash} # Test above is flawed as LanguageSet sorts by each element's hash, so the order will change from one invocation to the next. Sort a conversion to array instead. +GC.start sa = s.to_a.sort { |x, y| x.to_s <=> y.to_s } -sa == [1,[1,2],'hello'] +sa == [1,[1,2],hello] EOF