Calculation of critical shapes and stresses of surface sources of dislocations