Convert mat from BGR2RGB and then RGB2BGR again, it will work. The reason behind this crash dont know, but trying this way is working.
Add line cvtColor(cvMat, cvMat, CV_RGB2BGR) after cvtColor(cvMat, cvMat, CV_BGR2RGB);.