Reset data inputs pointers in Adapter before interface is destroyed #301
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Starting the PR mostly to see if the solution is the best.
The context is the following:
CGenFunctionBlock<T>::setupFBInterface
does its Voldermort-level-memory-magic, storing the data inputs and data outupts into member variablesmDIs
andmDOs
mDIs = paPeer->mDOs;
is done in each FB, meaning each FB has the pointer from the other, which is reseted tomLocalDIs
when disconnected.Two problems:
mLocalDIs
is set withmDIs
in the constructor, butmDIs
is set only afterwards ininitialize
, therefore this PE contrins the change in thisinitialize
to store the updated value ofmDIs
disconnect
(which resetsmDIs
withmLocalDIs
) is called after the destructor of the Adapter, specifically fromCAdapterConnection::performDisconnect
in its destructor. That means whent he destructor of the Adapter is called,mDIs
still has themDOs
value of the connected FB, and when the interface is destroyed inCGenFunctionBlock<T>::freeFBInterfaceData
really bad things happen.I tried calling
disconnect
in the destructor of the Adapter, but the call later toperformDisconnect
is not happy (probably because the FB was destroyed alreayd, but not sure)With the changes in the first commit of the PR, I don't get a crash. I'm surprised this was not detected before, so I'm not sure I'm doing something wrong. I used the ReferenceExamples from the Examples repository. There
Ex2a_05_Adapter
andEx3a_05_Adapter
have this issue. The particular case I see is that the Adapter has both Data Inputs and Data Ouputs, which is not the case for example of theATimeout
, but I didn't test too deep to see if this affects the context in which the crash occurs.In my opinion, the adapter should perform the disconnection in its destructor, and the
CAdapterConnection::performDisconnect
should not exist