[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Memory corruption (?) I don't understand
From: |
BERTRAND Joël |
Subject: |
Re: Memory corruption (?) I don't understand |
Date: |
Tue, 22 Jun 2021 19:28:47 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0 SeaMonkey/2.53.7.1 |
BERTRAND Joël a écrit :
> Trampas Stern a écrit :
>> Does the code run if you comment out 'lora_send("coucou", 7);
>
> Yes. To be honnest, if I comment out LDL_MAC_otaa(&mac), it runs.
>
>> Does it still crash with simple main() { _delay_ms(1000);
>> stty_print("hello");}
>>
>> That is start removing code until it works, when you find the line in
>> main that causes a crash, go into that function and start removing code
>> until it works. Slowly you will find the problem.
>
> I have tried (and I continue...) but I'm not sure that this bug is in
> LoRaWAN library. Indeed, LDL_MAC_otaa(&mac) shows my bug but, sometimes,
> just with a debug trace in main(), LDL_MAC_otaa(&mac) doesn't crash.
In lorawan/ldl_mac.c, you have :
enum ldl_mac_status LDL_MAC_otaa(struct ldl_mac *self)
{
...
fillJoinBuffer(self, U16(self->devNonce));
self->devNonce++;
arg.dev_nonce_updated.nextDevNonce = self->devNonce;
self->handler(self->app, LDL_MAC_DEV_NONCE_UPDATED, &arg);
self->tx.power = 0;
self->op = LDL_OP_JOINING;
...
}
If I comment out :
self->handler(self->app, LDL_MAC_DEV_NONCE_UPDATED, &arg);
Firmware doesn't crash. This pointer is a pointer to app_handler() in
./lorawan.c.
Now, I suppose that this pointer is modified. Thus, I have add a debug
trace :
enum ldl_mac_status LDL_MAC_otaa(struct ldl_mac *self)
{
enum ldl_mac_status retval;
union ldl_mac_response_arg arg;
...
unsigned char t[80];
snprintf(t, 80, "self->handler=%p\r\n", self->handler);
stty_print(t);
self->handler(self->app, LDL_MAC_DEV_NONCE_UPDATED, &arg);
self->tx.power = 0;
self->op = LDL_OP_JOINING;
...
}
and with this simple debug trace, it doesn't crash anymore !...
- Memory corruption (?) I don't understand, BERTRAND Joël, 2021/06/22
- Re: Memory corruption (?) I don't understand, Trampas Stern, 2021/06/22
- Re: Memory corruption (?) I don't understand, Ian Molton, 2021/06/22
- Re: Memory corruption (?) I don't understand, David Brown, 2021/06/22
- Re: Memory corruption (?) I don't understand, Trampas Stern, 2021/06/22
- Re: Memory corruption (?) I don't understand, BERTRAND Joël, 2021/06/22
- Re: Memory corruption (?) I don't understand,
BERTRAND Joël <=
- Re: Memory corruption (?) I don't understand, BERTRAND Joël, 2021/06/22
- Re: Memory corruption (?) I don't understand, Trampas Stern, 2021/06/22
- Re: Memory corruption (?) I don't understand, Trampas Stern, 2021/06/22
- Re: Memory corruption (?) I don't understand, BERTRAND Joël, 2021/06/22
- Re: Memory corruption (?) I don't understand, BERTRAND Joël, 2021/06/23
- Re: Memory corruption (?) I don't understand, BERTRAND Joël, 2021/06/23
- Re: Memory corruption (?) I don't understand, David Brown, 2021/06/23
- Re: Memory corruption (?) I don't understand, BERTRAND Joël, 2021/06/23
- Re: Memory corruption (?) I don't understand, Senthil Kumar, 2021/06/23
- Re: Memory corruption (?) I don't understand, BERTRAND Joël, 2021/06/23