this make MAVFTP got stucked and fcu reboot.
step by step:
1.clean up waypoints.
2.reboot.
3.use CTRL+X to Show FTP window.
4.delete whole TERRAIN directory.
5.reboot.
6.write waypoints. (remake TERRAIN directory)
7.use CTRL+X to Show FTP window.

But if exchange step 6 and 7, no issue occur.
Version
master branch today
Platform
[ ] All
[ ] AntennaTracker
[ ] Copter
[ * ] Plane
[ ] Rover
[ ] Submarine
Airframe type
defalut after reset
Hardware type
mindpx-v2
Logs
no log
I can't reproduce this with a cube.
I can't reproduce this with a cube.
I'll try it again.
there is a video that reproduce with cube.
MP: 1.3.69
ArduPlane: V4.1.0dev (19c02471)
https://drive.google.com/open?id=10vKB2JaKgDaKCpUyhL3DW2G_Hw0QPcJB
@rmackay9's steps to repro (from #13536):
I've reproduced this in master, Copter-4.0.1 and Copter-4.0.2-rc4
Repros on plane as well.
This is fixed in master and is included in Copter-4.0.2
@liang-tang, thanks very much for the report!
SITL with plane 4.0.5beta1
Stack overflow in thread FTP

Stack trace would be good. You will need to enable the operation according to the instructions there.
Steps to reproduce would be great!
@liang-tang,
Thanks very much for the follow-up.
By the way, I tried to reproduce this on Copter (latest) but wasn't able to. If it can be reproduced with Copter-4.0.3-rc1 then I'll stick it back on the Copter-4.0 issues list.
I think with Copter-4.0 we've done a good job of tracking and resolving bugs so getting it on this list is another good way to ensure it's not forgotten.
@rmackay9
The code is at /home/ubuntu/My_ArduPilot, and switched to Copter-4.0.3-rc1 branch.
Setp 1,
in directory /home/ubuntu/My_ArduPilot, execute
./Tools/autotest/sim_vehicle.py -v ArduCopter
Setp 2,
use CTRL+X to get content, then stack overflow.
BTW,
after increased stack size of ftp thread to 8k(just have a try), ftp works well.
and I got the root directory of ubuntu(version 16.04)

It may be that too many files are read, causing a stack overflow. Stack usage is positively correlated with the number of files read.
Thanks @liang-tang ! Reproduced on ArduCopter-beta, but does not trivially reproduce on master.
@rmackay9 we might be missing a patch into the Copter beta?
@peterbarker we read ardupilot directory on master, but read root directory on Copter beta, different directory.

f504009287221c7fda9cfa9c389a13af702aa9fd is probably the missing patch
We don't run the check-stack stuff on master because the pthread-attr-set-stack call we make doesn't work correctly.
Plane beta is also missing the patch.
I think we can close this issue because it's fixed in master. Just as a side note, getting the fix into a stable branch is a separate thing not related to having the issue open.
I just found this thread because I got this issue reported by SITL in ubuntu 20.04. In 4.0.5 apparently the f504009 patch was not present and the error was there, I cherry-picked the patch and now it is working nicely.
@Davidsastresas, txs for the feedback. I think this patch is included in Plane-4.0.6 that is available for beta testing. Plane isn't my baby but it should be there.
That patch is not in the current ArduPlane beta.
It would be cool to include it, the patch has been there since January!
@Davidsastresas, Tridge has confirmed that this is included in the Plane beta so if you get a chance to test with the latest beta that would be good, txs again!
@Davidsastresas so the patch isn't there but the code is. Are you able to reproduce this bug on either of Copter or Plane betas?
I just checked both, copter and plane betas and it works so the patch should be there. Thank you!