cudaMalloc fails with access violation error in emulation mode

I’m sorry because of all my cudaMalloc troubles. :">
This code runs without any trouble in normal mode, but it causes “Access violation reading location 0x0000006b.” error in emulation mode
allocbytes = sizeof(COST) * count;
cudaMalloc((void**) &costs, allocbytes);

I need emulation mode to debug some errors.

Any help is really appreciated, my university project’s timelimit is about to come, :shiver: thanks to every one in this forum.

That is pretty obviously not a sensible pointer value you are trying to reference. What is COST and costs?

struct COST

{

float * cost;

SPLIT * split;

};

.

.

unsigned int allocbytes;

.

.

COST * costs;

allocbytes = sizeof(COST) * count;

cudaMalloc((void**) &costs, allocbytes);

thanks, i don’t know what i’m missing

Where are you allocating the pointers inside costs and what are you doing when the segfault happens?

The segmentation fault occurs in this line

[codebox]cudaMalloc((void**) &costs, allocbytes);[/codebox]

The allocation of the pointers inside costs is a bit complicated and may be totally wrong, but the running never reach there any way

[codebox]float * t;

cutilSafeCall(cudaMalloc((void**) &t, sizeof(float) * splitcount));

#ifdef CUDADEBUG

	bytes+=sizeof(float) * splitcount;

#endif

	//float * t2 = t;

	cutilSafeCall(cudaMemcpy(costs+i, &t, sizeof(float*), cudaMemcpyHostToDevice));[/codebox]

and

[codebox] cutilSafeCall(cudaMalloc((void**) &t, sizeof(SPLIT) * splitcount));

#ifdef CUDADEBUG

	bytes+=sizeof(SPLIT) * splitcount;

#endif

	cutilSafeCall(cudaMemcpy((void**) reinterpret_cast<float*>(costs+i)+1,

		&t, sizeof(SPLIT*), cudaMemcpyHostToDevice));[/codebox]

I think this topic is exactly the same problem as mine, there’s no replies though <img src=‘http://hqnveipbwb20/public/style_emoticons/<#EMO_DIR#>/crying.gif’ class=‘bbc_emoticon’ alt=’:’(’ />

[topic=“83508”]Debug Emulation, Emulation Mode[/topic]

Could it be a bug in cuda runtime?