[
https://issues.apache.org/jira/browse/GEODE-8436?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17180516#comment-17180516
]
ASF GitHub Bot commented on GEODE-8436:
---------------------------------------
alb3rtobr opened a new pull request #635:
URL: https://github.com/apache/geode-native/pull/635
A segmentation fault is produced 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();
```
`getPdxType()` returns `nullptr`, so in the next line, there is segmentation
fault when calling `pt->getPdxFieldTypes()`.
I have seen the problem appears when `PdxInstanceImpl::getPdxType()` calls
`PdxTypeRegistry::getPdxType()` and this method returns `nullptr` due to it is
not able to found an entry in its `typeIdToPdxType_` map. But I have verified
that at that point, the corresponding entry in `pdxTypeToTypeId_` map exists,
so the maps were not aligned.
I checked how they are updated, and I realized that two different locks are
being used to update `pdxTypeToTypeId_` map first and `typeIdToPdxType_` after.
So it seems the error is caused due to `typeIdToPdxType_` is checked before it
is updated.
The test case implemented does not fail every time it is executed, I have
not been able to find a configuration to make it fail always, but I have not
seen it failing after the change in `PdxTypeRegistry`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Several threads calling PdxInstanceFactory::create() causes seg fault
> ---------------------------------------------------------------------
>
> Key: GEODE-8436
> URL: https://issues.apache.org/jira/browse/GEODE-8436
> Project: Geode
> Issue Type: Bug
> Components: native client
> Reporter: Alberto Bustamante Reyes
> Priority: Major
> Attachments: main.cpp
>
>
> 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:
> {code}
> void PdxInstanceImpl::toDataMutable(PdxWriter& writer) {
> auto pt = getPdxType();
> std::vector<std::shared_ptr<PdxFieldType>>* pdxFieldList =
> pt->getPdxFieldTypes();
> {code}
> 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:
> {code}
> #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)
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)