A stress relaxation mechanism through buckling-induced dislocations in thin films