Skip to content
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

1.4.4 stack on startup is sometimes larger #18

Open
AlexKlimaj opened this issue Sep 26, 2023 · 4 comments
Open

1.4.4 stack on startup is sometimes larger #18

AlexKlimaj opened this issue Sep 26, 2023 · 4 comments

Comments

@AlexKlimaj
Copy link

AlexKlimaj commented Sep 26, 2023

I recently updated to 1.4.4. I noticed that I started getting a random hardfault on boot and traced it to the AFBR driver sometimes using more stack causing it to overrun the amount allocated to the task.

Currently I have 1872 bytes allocated to the task. After increasing that, I found that the AFBR sometimes uses 2068 on startup instead of 1876.

Upon power cycling, it appears to be random how much stack it uses. Can you tell me why this is the case?

@c-berger
Copy link
Contributor

Hi Alex,

I am not aware of such a issue. The startup sequence should be deterministic. But since there is real hardware involved, it could happen that the path through the code is slightly different depending on what values are obtained from the device. For example, the PLL lock time may vary slightly each time resulting in more or less repetitions when polling its state via SPI.

Just to make sure, when you talk about startup, you mean the Argus_Init function? Further, when you say random, everything stays the same, i.e. same configuration, same device, etc.?
Does this happen for a specific device only (which one?) or can you reproduce it with multiple devices (also, which ones?)?
How did you measure the stack? Simply by checking what memory has been changed after calling Argus_Init? Just wondering if it could have the same stack usage but sometimes not using the allocated space...

Best regards,
Christoph

@AlexKlimaj
Copy link
Author

On the same device through different power cycles, the stack will vary on startup. The behavior is the same across multiple units.

I only noticed this after upgrading to 1.4.4. It might be occurring on 1.3.5 but didn't cause a hardfault because it used less overall stack.

Stack is measured in nuttx with top.

@c-berger
Copy link
Contributor

Ok, thanks for the information.
Is it possible to simply increase the stack size to get rid of the issue?

@AlexKlimaj
Copy link
Author

Yes I increased the stack and the hardfault was resolved. But I would like to know what the library is doing internally that it can dynamically change the amount of stack required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants