{ gROOT->Reset(); Int_t nR = 2; TCanvas *CC = new TCanvas("CC","Split in 2",1000,500); CC->Divide(nR,1); for (Int_t jj = 0; jj < nR; ++jj) { CC->cd(jj+1); if (jj) gPad->SetLogy(); //Causes the error // if (! jj) gPad->SetLogy(); //Works } printf("\nGet here\n"); CC->cd(0); }