Hello, guys,

I’ve been looking all over the internet to find the solution to this problem. I am getting ‘ptxas’ died with status 0xC0000005 (ACCESS_VIOLATION) linker error when I am trying to compile my program. I am doing SHA 256 implementation and here is the excerpt:

```
#define PUT_UINT32_BE(n,b,i) \
{ \
(b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
(b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
(b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
(b)[(i) + 3] = (unsigned char) ( (n) ); \
}
typedef struct {
SHA256_LONG state[8]; /* Intermediate hash state */
} sha256_context;
__device__ void sha256_finish (sha256_context *ctx, unsigned char *output)
{
int i;
for (i = 0; i <8; i++)
PUT_UINT32_BE(ctx->state[i], output, i * 4);
}
__device__ void sha256_run (SHA256_CHAR *input, unsigned char *output)
{
sha256_context ctx;
sha256_start (&ctx);
sha256_compute (&ctx, input);
sha256_finish (&ctx, output);
}
__global__ void sha256_kernel (unsigned char *input, unsigned int size, unsigned char *output, int totalThreads)
{
int threadIndex = threadIdx.x + blockDim.x * blockIdx.x;
if (threadIndex > totalThreads - 1)
return;
/* Is this the last thread? If so, we have to compute hash for current block and padding, if any. */
if (threadIndex == totalThreads - 1) {
/* patikrinti ar nera viskas suhashinta, nes gali buti taip kad */
/* we check if message size is multiple of block size */
if (size % 64 == 0) {
/* here we need to hash only padding */
/* cia yra kaikas blogai, nes message len yra tik 32 bitu */
/*memcpy(sha256_padding + 60, &size, 8);
sha256_run (sha256_padding, output + threadIndex * SHA256_HASH_SIZE);*/
} else {
/* here we have to calculate how big padding has to be
* in worst case we might need to hash two more blocks */
}
return;
}
sha256_run (input + threadIndex * SHA256_BLOCK_SIZE, output + threadIndex * SHA256_HASH_SIZE);
}
```

I just don’t know what the problem is. If I comment out the loop in sha256_finish function I won’t get any compilation errors. Can anyone help me? Thank you.

Tadas