Issue with pointers inside kernel


I am having an issue with pointers inside the kernel. When I comment that line, the kernel works just fine. When its active, it crashes the driver and I have to restart the PC. In the 1 second between the start of the application and the crash, I managed to see an access violation error generated in the visual studio. I am not sure why this is causing the driver to crash. This code was imported from a C code and it works perfectly on the CPU. here is the kernel code:

__device__ clause* dsolver_propagate(solver* D, vecp* dws)


    lbool*  values = D->assigns;

    clause* confl  = (clause*)0;

    lit*    lits;

   while (confl == 0 && D->qtail - D->qhead > 0){

        lit  p  = D->trail[D->qhead++];

        clause **begin = (clause**)dvecp_begin(dws);

        clause **end   = begin + dvecp_size(dws);

        clause **i, **j;  



       for (i = j = begin; i < end; ){

            if (dclause_is_lit(*i)){

            *j++ = *i;      <--------------------------- Causes error




        D->stats.inspects += j - (clause**)dvecp_begin(dws);

        dvecp_resize(dws,j - (clause**)dvecp_begin(dws));


    return confl;


__global__ void

propagateGPU1(solver* D, clause* dconfl, vecp* dws )


	dconfl  = (clause*)0;

	dconfl = dsolver_propagate(D, dws);


The line that causes the crash is with the arrow. When it is commented, the program runs with no issues, even when the if statement is still active (empty but the test is active which uses one of the pointers). There are more code inside the device funtion but I have commented them out to debug and found out that line that causes the crash.

Any help is appreciated…