Free-fall then crash when flying in Guided Mode (logs attached)

I am running ArduCopter master branch V4.1.0-dev (24fccd5d) on omnibusf4pro FC. I have customised the firmware code slightly and made one custom thread running with AP_Scheduler in Copter.cpp.

I have used RC channels pwm values to fly the drone in guided mode, i have used 2 rc channels, RC7 for takeoff in guided mode & landing and RC6 for starting the mission by reading a file from SD card continuously and then sending the global coordinates data from file as waypoint navigation command in guided mode. I am updating my custom thread at 25Hz and set 200usecs maximum expected time to complete (SCHED_TASK(custom_code_loop,25,200)). But i am sending waypoint commands at 0.4sec interval or 2.5Hz.

I have run and checked these changes on SITL thoroughly, and everything works fine in SITL everytime like i want it to. But when actually trying this on omnibusf4pro FC, my drone not performing in same manner. Sometimes everything works fine but few times there has been some issues and crashes.

I am sharing logs of my last 2 flights, in first log drone performs well and completed the whole path as it suppose to. Log of first flight looks fine even though there was a GPS_glitch initially.

first log

In second log, drone covered more than half of the path well, but closer to the end it suddenly free-fall, speed of the motors suddenly decreased in guided mode just like when someone suddenly decrease the throttle to minimum when flying drone manually. Due to free-fall, it crashed but i observed this kind of misbehaviour/free-fall couple of times in last 10-12 flights.

second log

I did observed the logs whenever it free-falls while flying but logs don’t show up any error, only change i found when i was not running my custom code that during auto-analysis of logs Test: PM was not showing any failure or warning, but after running my custom code, there is always some WARN or FAIL. Please help finding the possible reason for this misbehaviour/free-falls.

Do you have RC connected or just telem radio?

Just RC receiver connected, telemetry radio not connected

Could be couple reasons, I have different clones of F4. One of them do have similar erratic ppm input problem, on that one I have removed the inverter IC connected to UART6 and also disabled it. By changing BRD_ALT_CONFIG to 3 to add UART4 and use it for GPS. No problem so far.

i don’t think in my case i have any RCIN issues, i have also checked my logs Data table in detail, RCIN values for channel 6 & 7 is as expected throughout the flight time, just after the free-fall i tried to land the drone safely by quickly triggering land mode twice but it crashed to the ground before that

i am not sure what causing the issue but clearly something going wrong with the RCOU pwm outputs of motors in the second log

This kind of log seems normal when landing in guided mode, but here this is not normal cause this landing event i have triggered manually as drone crashes, this reduction in pwm outputs of motors definitely caused free-fall but i didn’t get why this happened, please help in clearing the picture, what can be the possible issue