Issue #25498: Merge ctypes crash fix from 3.4 into 3.5