Bug 578462 - Improper handling of the "mInterruptResp" variable in CIPComLayer
Summary: Improper handling of the "mInterruptResp" variable in CIPComLayer
Status: UNCONFIRMED
Alias: None
Product: 4DIAC
Classification: IoT
Component: FORTE (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-31 01:50 EST by nan zhou CLA
Modified: 2023-03-24 03:34 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nan zhou CLA 2022-01-31 01:50:43 EST
FORTE is started as a TCP/IP server. When receiving a huge data stream of which the size is larger than the size of the pre-defined socket buffer specified with "FORTE_IPLayerRecvBufferSize", the CFDSelectHandler will call the recvData() function of CIPCommlayer continuously and "mInterruptResp" will be set to "e_Nothing" during this procedure. Then, when the processInterrupt() of CIPCommlayer is called by another thread (event chain), the expected response code (such as "e_ProcessDataOk") has been set to a wrong value. Therefore, the received data will not be handled by the top layer any longer.
Comment 1 Eclipse Genie CLA 2022-01-31 02:50:57 EST
New Gerrit change created: https://git.eclipse.org/r/c/4diac/org.eclipse.4diac.forte/+/190188
Comment 2 nan zhou CLA 2023-03-24 03:00:32 EDT
To reproduce this BUG, one can easily enable the Lua module in forte (after the 1.13 version). In the 2.0 version, when enabling the "FORTE_DYNAMIC_TYPE_LOAD" option, the "FORTE_IPLayerRecvBufferSize" will not be changed from the default 1500 to a larger one (e.g., 20000). In this case, deploying dynamic-type FBs via 4DIAC will cause an error.
Comment 3 nan zhou CLA 2023-03-24 03:34:03 EDT
In the first thread, we know the function call procedure is:
CFDSelectHandler->CIPCommlayer::recvData()-> mInterruptResp = e_Nothing; ...; mInterruptResp = e_ProcessDataOk; m_poFb->interruptCommFB(this);  

Then the ecet thread is wakened up and finally call CIPCommlayer::processInterrupt(), where mInterruptResp will be checked if(e_ProcessDataOk == mInterruptResp).

Note, during wakening up of ecet thread, the CFDSelectHandler thread may call CIPCommlayer::recvData() again and again...(since there are data available). Then,mInterruptResp will be set to e_Nothing. Besides, mBufFillSize is set to cg_unIPLayerRecvBufferSize during the first call. Then CIPCommlayer::handledConnectedDataRecv() will not continue to receive data from socket. Now, mInterruptResp will not be updated any longer, and the ecet thread cannot receive interrupt as well.

At this time, these two threads are "deadlocked".