tags:

views:

25

answers:

1

I'm currently doing some tests using Cairo to replace some existing GDI/GDI+ code in Visual C++ 2010 and it seems to be working fine, but I'm getting an error message each time I close down my application :

"First-chance exception at 0x68e629dc in CairoTest.exe: 0xC0000005: Access violation reading location 0xabababa7"

This error only happens if I've called cairo_paint(cr) while the application is running - if I comment this line out, it disappears. The only Cairo code in my application so far is :

CChildView::CChildView()
{
     testsurface = cairo_image_surface_create_from_png("BlackShinyBackground.png");
}

CChildView::~CChildView()
{
     cairo_surface_destroy(testsurface);
}

void CChildView::OnPaint()
{
     CPaintDC dc(this);

     cairo_surface_t *surface = cairo_win32_surface_create(dc.m_hDC);
     cairo_t *cr = cairo_create (surface);

     cairo_set_source_surface(cr, testsurface, 0, 0);
     cairo_paint(cr);
     cairo_destroy (cr);
     cairo_surface_destroy (surface);
}

Can anybody point me in the direction of what I'm doing wrong?

Like I said, the code appearsto be working fine, but I don't like just ploughing on regardless when I can see errors.

+1  A: 

A first chance exception doesn't necessarily mean much -- they're a routine part of Windows' memory management. Basically, any time you access something that's in virtual memory (e.g., on the paging file) a first chance exception is created. The OS handles it by paging in the required data into physical memory, then your code can continue executing.

If/when you see a second-chance exception, it means the OS didn't handle the exception, so unless you have a handler for it in your code, chances are pretty good that is signals a real problem.

Jerry Coffin
Thanks, that explains a lot. I think I need to do a bit more digging to find out exactly what's going on. I just hate having the debugger churning out error messages - experience tells me that they have a nasty habit of coming back to bite you if you ignore them.
Redeye
Right, I've done a bit more research on this and actually found a really good article on it here :http://blogs.msdn.com/b/davidklinems/archive/2005/07/18/440150.aspxFurther inspection does prove that it's something in the Cairo DLL that's causing the exception. However, I've satisfied my curiousity about what's going on so I'm going to leave it and not worry about it for now.Thanks for you help Jerry.
Redeye