This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

GateMutex assertion failure caused by to many failed connection attempts on socket

Other Parts Discussed in Thread: SYSBIOS

Hello eveyone,

Code Composer Version: 5.5.0.00077

MCSDK Version: 02.01.02.06

NDK Version: 2.20

We have an application running on an evm c6678 evaluation board which uses a socket to connect via TCP to a server application running on a windows box. If the server program is running and the connection is successful, the system is able to run with no issue's. However, if the application is not running then the system will loop around continuing to try to get a connection and will do so successfully for between 20 minutes to an hour. Unfortunately, it will inevitably raise the error:

ti.sysbios.gates.GateMutex: line 97: assertion failure: A_badContext: bad calling context. See GateMutex API doc for details.
xdc.runtime.Error.raise: terminating execution

It is possible for us to implement a watchdog timer to try and circumvent this but since we haven't discovered what is causing the problem I'm afraid it will only be a temporary bandaid to a deeper issue.


I originally suspected there might be some leaks in the code, but after some investigation it seems fairly clear that this is not the case.

Oh, also, this is a blocking socket - if that's relevant.

This is my first time posting with the e2e community so please let me know if you need more information from me.


Regards,

Stephen

  • The error indicates that GateMutex_enter() is being called from within a Hwi or Swi context rather than a Task context.

    This is likely coming from a printf(), System_printf(), or rand() call within a Hwi or Swi function.

    To guarantee thread safety when application code invokes RTS library APIs, SYS/BIOS installs a GateMutex instance as the runtime support library's lock/unlock protection mechanism.

    If your application absolutely must call RTS library APIs from within a Hwi or Swi function, you can have a GateHwi instance get installed as the lock/unlock mechanism by adding the following to your config script:

    var BIOS = xdc.useModule('ti.sysbios.BIOS');
    BIOS.rtsGateType = BIOS.GateHwi;

    Keep in mind that this type of Gate globally disables interrupts while the RTS function executes.

    Alan