Uploaded image for project: 'Geode'
  1. Geode
  2. GEODE-8436

Several threads calling PdxInstanceFactory::create() causes seg fault

    XMLWordPrintableJSON

Details

    Description

      I have seen a problem when "PdxInstanceFactory::create()" is called by several threads that are registering the same new pdx type.

      The core is produced here:

      void PdxInstanceImpl::toDataMutable(PdxWriter& writer) {
         auto pt = getPdxType();
         std::vector<std::shared_ptr<PdxFieldType>>* pdxFieldList =
             pt->getPdxFieldTypes();
      

      The problem is that "getPdxType()" returns nullptr, so in the next line, there is segmentation fault when calling "pt->getPdxFieldTypes()".

      The issue can be reproduced using the attached client, and executing it using 8 threads. This is the stack got in gdb:

      #0  apache::geode::client::PdxType::getPdxFieldTypes (this=0x0) at /home/alb3rtobr/CLionProjects/Nordix/geode-native/cppcache/src/PdxType.hpp:178
      #1  0x00007f43dc4651b7 in apache::geode::client::PdxInstanceImpl::toDataMutable (this=0x7f43c0001600, writer=...) at /home/alb3rtobr/CLionProjects/Nordix/geode-native/cppcache/src/PdxInstanceImpl.cpp:1336
      #2  0x00007f43dc4650fd in apache::geode::client::PdxInstanceImpl::toData (this=0x7f43c0001600, writer=...) at /home/alb3rtobr/CLionProjects/Nordix/geode-native/cppcache/src/PdxInstanceImpl.cpp:1327
      #3  0x00007f43dc444971 in apache::geode::client::PdxHelper::serializePdx (output=..., pdxObject=warning: RTTI symbol not found for class 'std::_Sp_counted_ptr_inplace<apache::geode::client::PdxInstanceImpl, std::allocator<apache::geode::client::PdxInstanceImpl>, (__gnu_cxx::_Lock_policy)2>'
      warning: RTTI symbol not found for class 'std::_Sp_counted_ptr_inplace<apache::geode::client::PdxInstanceImpl, std::allocator<apache::geode::client::PdxInstanceImpl>, (__gnu_cxx::_Lock_policy)2>'
      std::shared_ptr<apache::geode::client::PdxSerializable> (use count 3, weak count 0) = {...})
          at /home/alb3rtobr/CLionProjects/Nordix/geode-native/cppcache/src/PdxHelper.cpp:77
      #4  0x00007f43dc44b4bc in apache::geode::client::PdxInstanceFactory::create (this=0x7f43c7ffecc8) at /home/alb3rtobr/CLionProjects/Nordix/geode-native/cppcache/src/PdxInstanceFactory.cpp:53
      #5  0x000000000040de2f in doPut () at /home/alb3rtobr/CLionProjects/dummy-client/main.cpp:60
      #6  0x0000000000427767 in std::__invoke_impl<void, void (*)()> (__f=@0x2561aa8: 0x40d860 <doPut()>) at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/invoke.h:60
      #7  0x00000000004276fd in std::__invoke<void (*)()> (__fn=@0x2561aa8: 0x40d860 <doPut()>) at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/invoke.h:95
      #8  0x00000000004276d5 in std::thread::_Invoker<std::tuple<void (*)()> >::_M_invoke<0ul> (this=0x2561aa8) at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/thread:234
      #9  0x00000000004276a5 in std::thread::_Invoker<std::tuple<void (*)()> >::operator() (this=0x2561aa8) at /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/thread:243
      #10 0x0000000000427589 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> > >::_M_run (this=0x2561aa0)
      
      

      Attachments

        1. main.cpp
          3 kB
          Alberto Bustamante Reyes

        Issue Links

          Activity

            People

              alberto.bustamante.reyes Alberto Bustamante Reyes
              alberto.bustamante.reyes Alberto Bustamante Reyes
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: