Commanded flight path and altitude anomaly during normal waypoint navigation

The other day, I encountered an anomaly during an otherwise normal flight. During a segment between two consecutive waypoints—one at 20 m and the next at 80 m—instead of performing the expected steady and progressive climb, the aircraft rapidly climbed to the target altitude. In addition to this, it veered considerably off-course. This deviation does not appear to have been caused by a near-stall due to the steep climb, but rather by a roll commanded by ArduPilot.

The mission included other identical waypoint transitions, one of which is included in the attached log file. All those behaved as expected. The log clearly shows that the TECS commanded the steep climb instead of a gradual one, and the attitude control commanded the roll that led to the off-course trajectory.

What I am failing to understand is why. The next climb in the mission is identical in terms of waypoint settings. There is no RC nudge input during the anomaly. So what can be the reason for this?

Log: Deleted

It seems the log file was deleted so here it is again:

I just had the same issue and found this thread searching for a remedy.

Terrain Following is the issue here. The behavor is completely obscure because it does not care that Bit 14: In AUTO - climb to next waypoint altitude immediately instead of linear climb.
IMHO it’s a bug.

It is sufficient to have terrain-following enabled for auto and if the next waypoint has terrain-based altitude set, you get this behavior.