-
Notifications
You must be signed in to change notification settings - Fork 17.4k
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
Potential thread stack overflow in AP_SmartAudio::loop
#28374
Comments
AP_SmartAudio::loop
nice find, thanks! can you open a PR for that? |
@tridge Sure! is just changing stack size enough? |
On Tue, 15 Oct 2024, mirusu400 wrote:
@tridge Sure! is just changing stack size is enough?
Problem with just increasing stack size is that we have a *lot* of
threads, and adding 512 bytes to each of them is a significant hit to
resources on smt32.
|
mavlink_sha256_update uses 416 bytes on the stack! mavlink_sha256_ctx only seems to be 90 bytes and "zero" seems to be 72 bytes. Where is the rest? |
On Fri, 18 Oct 2024, Tim Tuxworth wrote:
nice find, thanks! we could either allocate the sha256 context for the mavlink signing separately
mavlink_sha256_update uses 416 bytes on the stack! mavlink_sha256_ctx only seems to be 90 bytes and "zero" seems to be 72 bytes. Where is the rest?
You know there's only 768 bytes allowed, right?
... and the information *is* there :-)
|
That's kind of my point. If it's correct then one single method is consuming 416 bytes out of 768 bytes of stack space. I'm saying this is what should be fixed, but I can't see how just allocating the context would do it. There is still 300ish bytes being put on the stack even once you take account of the context. |
Bug report
Issue details
While some detailed build configuration, There are potential stack overflow in thread function named
AP_SmartAudio::loop
.ardupilot/libraries/AP_VideoTX/AP_SmartAudio.cpp
Lines 52 to 70 in b36f539
In this line,
AP_SmartAudio::loop
Allows 768 stack size.However, after manually checking stack, it might have 1040 Bytes in with some detailed configurations.
Steps to produce
boards.py
, Add this line:This will help you automatically calculating stack size of each function.
Now we can get stack usage file (*.su) for each source file, So we can manually check stack size of each function.
In case of
AP_SmartAudio::loop
:There are large call stack with this flow:
So, there are potentially occur stack overflow in
AP_SmartAudio::loop
Thread function.Version
Commit 0e72fc7
Platform
[ ] All
[ ] AntennaTracker
[ ] Copter
[ ] Plane
[x] Rover
[ ] Submarine
I've only checked
Rover
yet, but I think all platforms have same issues.Hardware type
AnyleafH7
The text was updated successfully, but these errors were encountered: