The example receiveHello sometimes crashes with a memory fault when the receive loop begins:
$ ./receiveHello -o 192.168.2.1 -c 40000
...
20240101-02:41:13.326326 Info: tlc_if.c:420 TRDP Stack Version 3.0.24.39(trunk): successfully initiated
20240101-02:41:13.326326 Info: tlc_if.c:424 VOS Version 3.0.0.1(trunk): successfully initiated
...
20240101-02:41:13.331326 Info: tlc_if.c:672 TRDP session opened successfully
Memory fault
The problem seems to be caused by an uninitialzed variable noDesc. The problem disappears after initializing the variable with VOS_INVALID_SOCKET either in receiveHello.c or in tlc_if.c:
--- src/common/tlc_if.c (revision 2439)
+++ src/common/tlc_if.c (working copy)
@@ -1434,6 +1434,7 @@
vos_getTime(&now);
vos_clearTime(&appHandle->nextJob);
+ *pNoDesc = VOS_INVALID_SOCKET;
trdp_pdCheckPending(appHandle, pFileDesc, pNoDesc, TRUE);
#if MD_SUPPORT
It has to be ensured that the calling application is calling tlc_getIntervall for the first time with NoDesc == VOS_INVALID_SOCKET. For the following calls it is correct to call tlc_getInterva() with the last returned NoDesc.
Dear Armin-Hagen,
OK, that's understood.
But in that case: multiple examples don't follow this rule. They use declare "INT32 noDesc" in the loop, so this variable is not initialized at all. Suggested patch: move it outside the loop and initialize it.
Patch for examples receiveHello.c / sendData.c / sendHello.c:
Last edit: Renaat Debaene 2024-05-30
All tests/examples handling noDesc now in the same way - definition and initialisation with TRDP_INVALID_SOCKET outside the loop with tlc_getInterval()/voc_select().