zeroc-ice / ice

All-in-one solution for creating networked applications with RPC, pub/sub, server deployment, and more.
https://zeroc.com
GNU General Public License v2.0
2.03k stars 592 forks source link

Ruby test crash on macos adding to value factory manager #1924

Open bernardnormier opened 6 months ago

bernardnormier commented 6 months ago

The Ice/objects ruby test occasionally crashes on macos on the first line of adding to the value factory manager: https://github.com/zeroc-ice/ice/blob/94ed83209787d3cb55f60318a9db5de1554a95c1/ruby/test/Ice/objects/AllTests.rb#L59

Reworking this test code slightly prevents the crash. That's what I did in #1923, but that's not a real fix.

Here is the full stack trace:

(lldb) target create --core "/cores/core.42945"
Core file '/cores/core.42945' (arm64) was loaded.
(lldb) bt
* thread #1
  * frame #0: 0x00000001857caa60 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x0000000185802c20 libsystem_pthread.dylib`pthread_kill + 288
    frame #2: 0x00000001856d84e8 libsystem_c.dylib`raise + 32
    frame #3: 0x0000000102dad968 libruby.3.3.dylib`rb_bug_for_fatal_signal + 160
    frame #4: 0x0000000102e97210 libruby.3.3.dylib`sigsegv + 96
    frame #5: 0x0000000185833584 libsystem_platform.dylib`_sigtramp + 56
    frame #6: 0x0000000102ec05a8 libruby.3.3.dylib`rb_id_table_lookup + 36
    frame #7: 0x0000000102eea568 libruby.3.3.dylib`rb_vm_search_method_slowpath + 116
    frame #8: 0x0000000102f061f4 libruby.3.3.dylib`vm_search_method_slowpath0 + 36
    frame #9: 0x0000000102eee930 libruby.3.3.dylib`vm_exec_core + 7064
    frame #10: 0x0000000102eebd48 libruby.3.3.dylib`rb_vm_exec + 444
    frame #11: 0x0000000102db4f4c libruby.3.3.dylib`rb_ec_exec_node + 188
    frame #12: 0x0000000102db4e28 libruby.3.3.dylib`ruby_run_node + 96
    frame #13: 0x00000001023f7f24 ruby`main + 104
    frame #14: 0x000000018547a0e0 dyld`start + 2360
(lldb) t 2
* thread #2
    frame #0: 0x00000001857c8340 libsystem_kernel.dylib`kevent + 8
libsystem_kernel.dylib`kevent:
->  0x1857c8340 <+8>:  b.lo   0x1857c8360               ; <+40>
    0x1857c8344 <+12>: pacibsp 
    0x1857c8348 <+16>: stp    x29, x30, [sp, #-0x10]!
    0x1857c834c <+20>: mov    x29, sp
(lldb) bt
* thread #2
  * frame #0: 0x00000001857c8340 libsystem_kernel.dylib`kevent + 8
    frame #1: 0x0000000102eccf44 libruby.3.3.dylib`timer_thread_func + 544
    frame #2: 0x0000000185802f94 libsystem_pthread.dylib`_pthread_start + 136
(lldb) t 3
* thread #3
    frame #0: 0x00000001857c59ec libsystem_kernel.dylib`__psynch_cvwait + 8
libsystem_kernel.dylib`:
->  0x1857c59ec <+8>:  b.lo   0x1857c5a0c               ; <+40>
    0x1857c59f0 <+12>: pacibsp 
    0x1857c59f4 <+16>: stp    x29, x30, [sp, #-0x10]!
    0x1857c59f8 <+20>: mov    x29, sp
(lldb) bt
* thread #3
  * frame #0: 0x00000001857c59ec libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018580355c libsystem_pthread.dylib`_pthread_cond_wait + 1228
    frame #2: 0x0000000185728b14 libc++.1.dylib`std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
    frame #3: 0x00000001205bb824 libIce.38a0.dylib`IceUtil::Timer::run(this=0x0000000129e3e828) at Timer.cpp:93:32
    frame #4: 0x00000001205bd050 libIce.38a0.dylib`decltype(*std::declval<IceUtil::Timer*>().*std::declval<void (IceUtil::Timer::*)()>()()) std::__1::__invoke[abi:ue170006]<void (IceUtil::Timer::*)(), IceUtil::Timer*, void>(__f=0x000060000365f688, __a0=0x000060000365f698) at invoke.h:308:25
    frame #5: 0x00000001205bcfd0 libIce.38a0.dylib`void std::__1::__thread_execute[abi:ue170006]<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void (IceUtil::Timer::*)(), IceUtil::Timer*, 2ul>(__t=size=3, (null)=__tuple_indices<2UL> @ 0x000000016db1ef7f) at thread.h:227:5
    frame #6: 0x00000001205bcc7c libIce.38a0.dylib`void* std::__1::__thread_proxy[abi:ue170006]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void (IceUtil::Timer::*)(), IceUtil::Timer*>>(__vp=0x000060000365f680) at thread.h:238:5
    frame #7: 0x0000000185802f94 libsystem_pthread.dylib`_pthread_start + 136
(lldb) t 4
* thread #4
    frame #0: 0x00000001857c59ec libsystem_kernel.dylib`__psynch_cvwait + 8
libsystem_kernel.dylib`:
->  0x1857c59ec <+8>:  b.lo   0x1857c5a0c               ; <+40>
    0x1857c59f0 <+12>: pacibsp 
    0x1857c59f4 <+16>: stp    x29, x30, [sp, #-0x10]!
    0x1857c59f8 <+20>: mov    x29, sp
(lldb) bt
* thread #4
  * frame #0: 0x00000001857c59ec libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018580355c libsystem_pthread.dylib`_pthread_cond_wait + 1228
    frame #2: 0x0000000185728b14 libc++.1.dylib`std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 28
    frame #3: 0x00000001202d9838 libIce.38a0.dylib`void std::__1::condition_variable::wait<IceInternal::EndpointHostResolver::run()::$_0>(this=0x0000600000f0f990, __lk=0x000000016dbaae60, __pred=(unnamed class) @ 0x000000016dbaac08) at condition_variable.h:148:5
    frame #4: 0x00000001202d90b0 libIce.38a0.dylib`IceInternal::EndpointHostResolver::run(this=0x0000600000f0f8f8) at IPEndpointI.cpp:604:32
    frame #5: 0x0000000120353a8c libIce.38a0.dylib`IceInternal::Instance::finishSetup(int&, char const**, std::__1::shared_ptr<Ice::Communicator> const&)::$_1::operator()(this=0x0000600003419d78) const at Instance.cpp:1478:83
    frame #6: 0x0000000120353a34 libIce.38a0.dylib`decltype(std::declval<IceInternal::Instance::finishSetup(int&, char const**, std::__1::shared_ptr<Ice::Communicator> const&)::$_1>()()) std::__1::__invoke[abi:ue170006]<IceInternal::Instance::finishSetup(int&, char const**, std::__1::shared_ptr<Ice::Communicator> const&)::$_1>(__f=0x0000600003419d78) at invoke.h:340:25
    frame #7: 0x00000001203539d0 libIce.38a0.dylib`void std::__1::__thread_execute[abi:ue170006]<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, IceInternal::Instance::finishSetup(int&, char const**, std::__1::shared_ptr<Ice::Communicator> const&)::$_1>(__t=size=2, (null)=__tuple_indices<> @ 0x000000016dbaaf7f) at thread.h:227:5
    frame #8: 0x0000000120353330 libIce.38a0.dylib`void* std::__1::__thread_proxy[abi:ue170006]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, IceInternal::Instance::finishSetup(int&, char const**, std::__1::shared_ptr<Ice::Communicator> const&)::$_1>>(__vp=0x0000600003419d70) at thread.h:238:5
    frame #9: 0x0000000185802f94 libsystem_pthread.dylib`_pthread_start + 136
(lldb) t 5
* thread #5
    frame #0: 0x00000001857c8340 libsystem_kernel.dylib`kevent + 8
libsystem_kernel.dylib`kevent:
->  0x1857c8340 <+8>:  b.lo   0x1857c8360               ; <+40>
    0x1857c8344 <+12>: pacibsp 
    0x1857c8348 <+16>: stp    x29, x30, [sp, #-0x10]!
    0x1857c834c <+20>: mov    x29, sp
(lldb) bt
* thread #5
  * frame #0: 0x00000001857c8340 libsystem_kernel.dylib`kevent + 8
    frame #1: 0x000000012057fc98 libIce.38a0.dylib`IceInternal::Selector::select(this=0x0000000129e050c8, timeout=-1) at Selector.cpp:665:22
    frame #2: 0x00000001205ac6b0 libIce.38a0.dylib`IceInternal::ThreadPool::run(this=0x0000000129e05050, thread=std::__1::shared_ptr<IceInternal::ThreadPool::EventHandlerThread>::element_type @ 0x0000600001d079d8 strong=3 weak=2) at ThreadPool.cpp:664:27
    frame #3: 0x00000001205ae694 libIce.38a0.dylib`IceInternal::ThreadPool::EventHandlerThread::run(this=0x0000600001d079d8) at ThreadPool.cpp:1199:16
    frame #4: 0x00000001205bacac libIce.38a0.dylib`decltype(*std::declval<IceInternal::ThreadPool::EventHandlerThread*>().*std::declval<void (IceInternal::ThreadPool::EventHandlerThread::*)()>()()) std::__1::__invoke[abi:ue170006]<void (IceInternal::ThreadPool::EventHandlerThread::*)(), IceInternal::ThreadPool::EventHandlerThread*, void>(__f=0x000060000365f6c8, __a0=0x000060000365f6d8) at invoke.h:308:25
    frame #5: 0x00000001205bac2c libIce.38a0.dylib`void std::__1::__thread_execute[abi:ue170006]<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void (IceInternal::ThreadPool::EventHandlerThread::*)(), IceInternal::ThreadPool::EventHandlerThread*, 2ul>(__t=size=3, (null)=__tuple_indices<2UL> @ 0x000000016dc36f7f) at thread.h:227:5
    frame #6: 0x00000001205ba8d8 libIce.38a0.dylib`void* std::__1::__thread_proxy[abi:ue170006]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void (IceInternal::ThreadPool::EventHandlerThread::*)(), IceInternal::ThreadPool::EventHandlerThread*>>(__vp=0x000060000365f6c0) at thread.h:238:5
    frame #7: 0x0000000185802f94 libsystem_pthread.dylib`_pthread_start + 136
(lldb) t 6
error: invalid thread #6.
pepone commented 1 month ago

I reverted the test to the previous code:

diff --git a/ruby/test/Ice/objects/AllTests.rb b/ruby/test/Ice/objects/AllTests.rb
index 5d712bc8b5..1bd404c5ce 100644
--- a/ruby/test/Ice/objects/AllTests.rb
+++ b/ruby/test/Ice/objects/AllTests.rb
@@ -40,15 +40,13 @@ end
 def allTests(helper, communicator)

     factory = MyValueFactory.new
-    valueFactoryManager = communicator.getValueFactoryManager()
-    test(valueFactoryManager != nil)
-    valueFactoryManager.add(factory, '::Test::B')
-    valueFactoryManager.add(factory, '::Test::C')
+    communicator.getValueFactoryManager().add(factory, '::Test::B')
+    communicator.getValueFactoryManager().add(factory, '::Test::C')
     #communicator.getValueFactoryManager().add(factory, '::Test::D')
-    valueFactoryManager.add(factory, '::Test::E')
-    valueFactoryManager.add(factory, '::Test::F')
-    valueFactoryManager.add(factory, '::Test::I')
-    valueFactoryManager.add(factory, '::Test::J')
+    communicator.getValueFactoryManager().add(factory, '::Test::E')
+    communicator.getValueFactoryManager().add(factory, '::Test::F')
+    communicator.getValueFactoryManager().add(factory, '::Test::I')
+    communicator.getValueFactoryManager().add(factory, '::Test::J')

     initial = Test::InitialPrx.new(communicator, "initial:#{helper.getTestEndpoint()}")

But I cannot reproduce, tested both debug and release builds with Ruby 3.3.4 macOS arm64