-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of #752 breaks v1.1 flow #772
Comments
Could you elaborate on why you believe the change to Unless I missed something, I don't see any change in behavior since
|
Note that @msmits-definium is right and he is referring to LW1.1 which has this function instead: static bool IsSticky( uint8_t cid )
{
switch( cid )
{
case MOTE_MAC_RESET_IND:
case MOTE_MAC_REKEY_IND:
case MOTE_MAC_DEVICE_MODE_IND:
case MOTE_MAC_DL_CHANNEL_ANS:
case MOTE_MAC_RX_PARAM_SETUP_ANS:
case MOTE_MAC_RX_TIMING_SETUP_ANS:
return true;
default:
return false;
}
} |
Thanks @ConnyBusy Still, I'd expect a function called That said, the problem described by @msmits-definium rather seems to be the missing check of a return value:
|
In LW1.1 not all sticky mac commands are removed on the same condition. Meanwhile e.g. |
I'm not much up to speed on 1.1 at this stage, but if that is so, I guess we may need a distinct function for that purpose. Nevertheless, I strongly believe that error handling is not optional - if a function may return an error, the return value should be checked rather than relying on incorrect data leading to a crash further down the chain. From a quick glance at the code, it appears that in case of failure of |
Thanks everyone for the helpful comments so far. To summarize the problem:
As mentioned above by user catsup, I've simply worked around this as follows, with a check on the return value of LoRaMacCommandsGetCmd:
For now this works well enough for me. I will leave it up to the discretion of the Stackforce people as to how they want to implement a permamennt solution fo this. |
Hi all, many thanks to @msmits-definium for creating a new issue. Thanks for all your analysis and reports. We will apply both, an error handling for I will push the fixes as soon as possible. |
Thanks @djaeckle. |
Hi @msmits-definium , thanks for the amendment, i will take it into account. |
In implementing #752 the CIDsStickyAnsCmds[] array got removed. This means that now every sticky command is removed.
This change breaks V1.1:
After joining, the MAC command RekeyInd is sent as DataUp (CID 11). The server responds with RekeyConf. This is now removed from the mac commands list because there is no check with CIDsStickyAnsCmds[]. It is however also removed a second time in ProcessMacCommands, case SRV_MAC_REKEY_CONF.
Because there is no check on the return value of LoRaMacCommandsGetCmd, the remove proceeds and results in an invalid deletion on the underlying linked list, It causes a hardfault on my LPC 54628.
See trace below which gives an idea of th flow:
[lorawan] initialisation
[lorawan] join;attempt=0
[lorawan] join=executing
[lorawan] lwn_network_task RECV
DEBUG - ProcessRadioTxDone
$ [lorawan] lwn_network_task RECV
DEBUG - ProcessRadioRxDone
LoRaMacCommandsAddCmd - cid: 11 <---- mac command added
DEBUG - ProcessRadioRxDone - exit
[lorawan] JOIN OK
[lorawan] MIB_DEV_ADDR: FC0023C4
[lorawan] join=success
[lorawan] session=get
[lorawan] SEND START
[lorawan] lwn_network_task RECV
DEBUG - ProcessRadioTxDone
[lorawan] lwn_network_task RECV
DEBUG - ProcessRadioRxDone
LoRaMacCommandsRemoveCmd - cid: 11 <---- mac command removed first time, OK
ProcessMacCommands - payload[macIndex]: 11
LoRaMacCommandsRemoveCmd - cid: 181 <----- mac command remove attempted 2nd time but on empty list, FAIL
As mentioned above this fail results in a system crash / hardfault.
The text was updated successfully, but these errors were encountered: