an illegal memory access was encounteredCUDA error check cudaMemcpy d_exf: an illegal memory access

int main(){

int w,t;
size_t sizeN=N*sizeof(int);
size_t sizeM= N*2* sizeof(int);
int *d_nodo1,*d_nodo2,*d_nome_est,*d_g;//device copies
float *exf;//host copies
float *d_dj,*d_exf;//device copies
//alloco array per la csr in ram
nodo1=(int*)malloc(N*sizeof(int));
nodo2=(int*)malloc(N*sizeof(int));
for(w=0;w<N;w++){
		nodo1[w]=0;
		nodo2[w]=0;
		}
nome_est=(int*)malloc(N*2*sizeof(int));
colonna1=(int*)malloc(N*sizeof(int));
colonna2=(int*)malloc(N*sizeof(int));
//colonne ordinate dopo qsort
colonna1f=(int*)malloc(N*sizeof(int));
colonna2f=(int*)malloc(N*sizeof(int));
//alloco array dj e exf per l'output in ram
exf=(float *)malloc(N*2*sizeof(float) );
for(w=0;w<N;w++){
	exf[w]=0;
		}
//allochiamo lo spazio sulla device per nodo1,nodo2,nome_int,nome_est,dj,exf
cudaMalloc((void**)&d_g,1*sizeof(int));
cudaMalloc((void**)&d_nodo1,sizeN);
cudaMalloc((void**)&d_nodo2,sizeN);
cudaMalloc((void**)&d_nome_est,sizeM);
cudaMalloc((void**)&d_dj,N*sizeof(float));
cudaMalloc((void**)&d_exf,N*2*sizeof(float));
acquisisciCSR(nodo1, nodo2,nome_est,colonna1,colonna2);

//copiamo i dati di input dall'host al device
cudaMemcpy(d_nodo1,&nodo1,sizeN,cudaMemcpyHostToDevice);
    cudaError_t error = cudaGetLastError();
    printf("%s",cudaGetErrorString(error));
    printf("CUDA error check cudaMemcpy nodo1: %s\n", cudaGetErrorString(error));fflush(stdout);

cudaMemcpy(d_nodo2,&nodo2,sizeN,cudaMemcpyHostToDevice);
    error = cudaGetLastError();
    printf("%s",cudaGetErrorString(error));
    printf("CUDA error check cudaMemcpy nodo2: %s\n", cudaGetErrorString(error));fflush(stdout);

cudaMemcpy(d_nome_est,nome_est,sizeM,cudaMemcpyHostToDevice);
    error = cudaGetLastError();
    printf("%s",cudaGetErrorString(error));
    printf("CUDA error check cudaMemcpy nome_est: %s\n", cudaGetErrorString(error));fflush(stdout);

//eseguiamo il kernel
//dim3 dimBlock(N, 1); //calcolo dei thread da rivedere è sbagliato
//dim3 dimGrid((int)ceil(N/dimBlock.x));
expected<<<1,N>>>(d_nodo1,d_nodo2,d_nome_est,d_exf,d_dj,d_g,uIndice);

//copiamo i risultati sull'host
cudaMemcpy(exf,d_exf,N*2*sizeof(float),cudaMemcpyDeviceToHost);
    error = cudaGetLastError();
    printf("%s",cudaGetErrorString(error));
    printf("CUDA error check cudaMemcpy d_exf: %s\n", cudaGetErrorString(error));fflush(stdout);

stampa(nodo1, nodo2);
for(t=1;t<N;t++){
	if(nome_est[t]!=0){
	printf("%d=%g\n",nome_est[t],exf[t]);
}

}
return 0;
}

Try to build this with Ubuntu14.04+cuda7.5 but hit following error, any suggestion?

test.cu(4): error: identifier “N” is undefined

test.cu(10): error: identifier “nodo1” is undefined

test.cu(11): error: identifier “nodo2” is undefined

test.cu(16): error: identifier “nome_est” is undefined

test.cu(17): error: identifier “colonna1” is undefined

test.cu(18): error: identifier “colonna2” is undefined

test.cu(20): error: identifier “colonna1f” is undefined

test.cu(21): error: identifier “colonna2f” is undefined

test.cu(34): error: identifier “acquisisciCSR” is undefined

test.cu(55): error: identifier “expected” is undefined

test.cu(55): error: identifier “uIndice” is undefined

test.cu(63): error: identifier “stampa” is undefined

12 errors detected in the compilation of “/tmp/tmpxft_000008c9_00000000-9_test.cpp1.ii”.

===================================

@sax92:

Did you try run your program under cuda-memcheck tool(under /usr/local/cuda-7.5/bin/cuda-memcheck)?

Looks like the posted sample code is incomplete, could you provide a compilable version?