While computational methods for the study of point defects in materials have received significant attention, methods for the investigation of grain boundaries require further development. In this study, we applied a genetic algorithm to find the atomic structure of grain boundaries in semiconductor materials with given Miller indices and investigated their electronic structure. Our study of the Σ3 (112) grain boundary in CdTe shows that the stability of grain boundaries can be greatly enhanced by breaking mirror symmetry, locally or globally. The resulting grain boundary can be electrically less harmful because the origin of the defect levels are removed from the middle of the band gap and the grain boundaries can serve as a channel for electron extraction.