The issue was caused by bezier handle positions that are almost (but not exactly) the same as the corresponding control point positions. This situation was caused by the Set Spline Type node, which converts Poly to Bezier splines with vector handle types. Usually vector handle types are not exactly on control points, but it happened here because two control points had the same position. Due to floating point accuracy issues (probably in calculate_vector_handle), the handle positions were slightly off the control point positions.
The solution is to just not compare floats exactly but with an epsilon, as one should usually do.