AltHold with Rangefinder problem

Hi everyone, there is a small drone for indoor flight, firmware AP 4.0.7. I take off in the stable, normally hangs both in height and horizon. Then take off in AltHold using lidar, the copter flies into the ceiling, the morors turn at full speed, it does not react to throtle. Lidar readings are reliable. The only thing that is very confusing is the values of CTUN. Alt and CTUN.Dalt, they go very much into the negative during takeoff.

what could be the problem?

What happens if you take off in Stabilize, establish a hover and then switch it AltHold?