Crash in _process_data_block

I’m trying to use ArvStream. Initially I simply looped on arv_camera_acquisition to grab images and was getting about 10 frames (2048x1536 mono) per sec. So next I’m trying to use AvrStream to supply 50 buffers. But I’m trying to avoid using signals and callbacks for now.

In my thread, I simply loop on

buffer = arv_stream_timeout_pop_buffer ( self.arvStream, 100000);
 // check and grab the image 
arv_stream_push_buffer ( self.arvStream, buffer);

So I set things up

self.arvStream	= arv_camera_create_stream (self.arvCamera, NULL, NULL, &error);
ERROR_CHECK ("arv_camera_create_stream", error)
bufferSize = arv_camera_get_payload (self.arvCamera, &error);
ERROR_CHECK ("arv_camera_get_payload", error)
for (int i = 0; i < 50; i++) {
	arv_stream_push_buffer (self.arvStream, arv_buffer_new (bufferSize, &error));
	ERROR_CHECK ("arv_stream_push_buffer", error)

grabberThread = [[NSThread alloc]	initWithTarget	:self
					selector	:@selector(grabThreadStream)
					object		:nil]; = @"GigE Grabber";
[grabberThread setThreadPriority:1.0];
[grabberThread start];

arv_camera_start_acquisition (self.arvCamera, &error);
ERROR_CHECK ("arv_camera_start_acquisition", error)

No Error returned but almost instantly it craches on line 328 of _process_data_block

memcpy ((( **char** *) frame->buffer->priv->data) + block_offset, arv_gvsp_packet_get_data (packet), block_size);

with the mention

arv_gv_stream (29): EXC_BAD_ACCESS

Strange thing: the first few times I tried this code, it work for about 500 to 1000 frames and then simply stopped. Restarted the camera , rebooted my MacBook… never works. I’ve got a console log with ARV_DEBUG-all:3. and my actual obj-c code at the beginning if interested…

Thanks for any clues…

1 Like

arv_buffer_new (bufferSize, &error) :face_with_symbols_over_mouth:

This is a case of code 18 ! By adding error checking to the aravis calls, I went too far and change the NULL for the pointer to the error variable, causing aravis to assume I had allocated the buffer.

I now get 28 2048x1536 mono8 frames per seconds. and 65 1024x748 ! :smile:

Sorry for the noise.

1 Like

That is an API design mistake. I should not have used void * as the type of preallocated memory, but char *. That would have triggered a compilation warning.

In my defense, gmalloc returns void *, and I always found weird to use char * as the type for a memory buffer.