BR: Crash in CameraDevice::Pimpl::handleFrame with JUCE8

After getting captures from my webcam for several minutes (sometimes longer, sometimes shorter), I get in a crash in

CameraDevice::Pimpl::handleFrame in line 301

It happens when the image to be duplicated seems to be bogus:

You can see the local variables are all uninitialized (debug mode on Windows = 0xdddddddd).

This then leads to a crash in the memcpy function.

There were quite a lot of D2D updates/fixes merged to the juce8 branch two days ago. Were you using this updated version when you saw this issue? If not, please could you confirm that the issue is still present with the most recent commits?

Unfortunately the issue is still present with the most up to date JUCE8 :frowning:

OK, thanks for checking.

Just FYI: the crash is much easier to reproduce in Release mode, as the pointers, variables, etc., are all garbage then, and in my case, this leads to a crash pretty often. In debug mode, I have to wait a lot longer to make it crash.

I suspect this is threading related, but I can’t work out exactly what’s going on. Do you get crashes in the CameraDemo example, or only in your own app? If the crashes are only in your own app, then the cause might be something to do with the image processing you’re doing on the main thread.

Please could you check whether the problem persists after applying this patch?

0001-CameraDevice-Simplify-data-shared-across-threads-to-.patch (4.0 KB)

As you can see from my callstack screenshot, this crash happens in the GrabberCallback, before any listeners are called.

In my callback I then do this:

	// Get a 4:3 version
	const auto	b = image.getBounds ();
	const auto	skip = b.getWidth () - int ( b.getHeight () * ( 4.0f / 3.0f ) );

	crtGlassReflections->fromImage ( image.getClippedImage ( b.reduced ( skip / 2, 0 ) ), false );

But the crash happens before that callback is ever reached.

I will try your patch soon.

After applying the patch, the crashes are gone. I’ve run the release version for over 80 minutes now, resizing the window, loading different tunes, etc., and not a single crash.

Thank you so much.

Great, thanks for the thorough testing. I’ll try to get that merged in shortly.

Is this still planned to be merged soon? Roland can not build ultraSID because I have this non-existing JUCE8 commit…

Hopefully, yes. Please bear with us, we’re very busy at the moment!