Re: Getting SIGSEGV in pixman
Hakki Dogusan <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <[email protected]> |
Hi, 20-05-2012 12:15 tarihinde, Hakki Dogusan wrote: > Hi, > > 19-05-2012 14:16 tarihinde, Chris Wilson wrote: >> On Sat, 19 May 2012 13:46:37 +0300, Hakki Dogusan<[email protected]> wrote: >>> Hi, >>> >>> (WinXP, MinGW (gcc-4.6.2), Cairo-1.12.2, Pixman-0.25.2) >>> >>> My program runs successfully with Cairo-1.10.2, but getting SIGSEGV with >>> 1.12.2. >> >> Is there any chance you can produce a small bit of code to reproduce the >> error? The on-stack values are within reason, so we need to dig further >> into the structures to find where the error occurs. A "bt full" would be >> a first step, followed by a p *surface on all the images and surfaces at >> various frames. >> -Chris >> > > (Thanks for responding) > > I prepared a minimal win32 sample using my compilation of Cairo-1.12.2; > uploaded here: > > http://www.dynaset.org/dogusanh/download/cairotest.zip (1.8MiB) > > I've put Code::Blocks project files, configuration files of Cairo and > pixman in it. > > When you resize the frame, program gets SIGSEGV. > > PS. To compile 1.12.2 I've added HAVE_UINT64_T compile flag to project; > otherwise getting compile error in cairo-wideint-private.h around line > 58. There uint64_t used in #if !HAVE UINT64_T block. If one changes them > to cairo_uint64_t than compilation stops at cairo-time.c around line > 113; "return t.QuadPart;". > > > -- > Regards, > Hakki Dogusan > > I've re-tested with Pixman-0.26.0, but unfortunately my program still crashes with Cairo-1.12.2, works with Cairo-1.10.2! Test program follows: #include <windows.h> #include <math.h> #include <cairo.h> //#if CAIRO_HAS_XLIB_SURFACE // #include <X11/Xlib.h> // #include <gtk/gtk.h> // #include <gdk/gdk.h> //#endif #if CAIRO_HAS_SVG_SURFACE #include <cairo-svg.h> #endif #if CAIRO_HAS_PDF_SURFACE #include <cairo-pdf.h> #endif #if CAIRO_HAS_PS_SURFACE #include <cairo-ps.h> #endif #if CAIRO_HAS_XCB_SURFACE #include <cairo-xcb.h> #endif #if CAIRO_HAS_XLIB_SURFACE #include <cairo-xlib.h> #endif #if CAIRO_HAS_WIN32_SURFACE #include <cairo-win32.h> #endif #if CAIRO_HAS_BEOS_SURFACE #include <cairo-beos.h> #endif #if CAIRO_HAS_DIRECTFB_SURFACE #include <cairo-directfb.h> #endif #if CAIRO_HAS_OS2_SURFACE #include <cairo-os2.h> #endif #if CAIRO_HAS_GLITZ_SURFACE #include <cairo-glitz.h> #endif #if CAIRO_HAS_QUARTZ_SURFACE #include <cairo-quartz.h> #endif #if CAIRO_HAS_ATSUI_FONT #include <cairo-atsui.h> #endif #if CAIRO_HAS_FT_FONT #include <cairo-ft.h> #endif /* Declare Windows procedure */ LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); /* Make the class name into a global variable */ const wchar_t* szClassName = L"CairoTest"; int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow) { HWND hwnd; /* This is the handle for our window */ MSG messages; /* Here messages to the application are saved */ WNDCLASSEX wincl; /* Data structure for the windowclass */ /* The Window structure */ wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */ wincl.style = CS_DBLCLKS; /* Catch double-clicks */ wincl.cbSize = sizeof (WNDCLASSEX); /* Use default icon and mouse-pointer */ wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION); wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION); wincl.hCursor = LoadCursor (NULL, IDC_ARROW); wincl.lpszMenuName = NULL; /* No menu */ wincl.cbClsExtra = 0; /* No extra bytes after the window class */ wincl.cbWndExtra = 0; /* structure or the window instance */ /* Use Windows's default colour as the background of the window */ wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND; /* Register the window class, and if it fails quit the program */ if (!RegisterClassEx (&wincl)) return 0; /* The class is registered, let's create the program*/ hwnd = CreateWindowEx ( 0, /* Extended possibilites for variation */ szClassName, /* Classname */ L"CairoTest", /* Title Text */ WS_OVERLAPPEDWINDOW, /* default window */ CW_USEDEFAULT, /* Windows decides the position */ CW_USEDEFAULT, /* where the window ends up on the screen */ 544, /* The programs width */ 375, /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ NULL, /* No menu */ hThisInstance, /* Program Instance handler */ NULL /* No Window Creation data */ ); /* Make the window visible on the screen */ ShowWindow (hwnd, nCmdShow); /* Run the message loop. It will run until GetMessage() returns 0 */ while (GetMessage (&messages, NULL, 0, 0)) { /* Translate virtual-key messages into character messages */ TranslateMessage(&messages); /* Send message to WindowProcedure */ DispatchMessage(&messages); } /* The program return-value is 0 - The value that PostQuitMessage() gave */ return messages.wParam; } static void snap_point (cairo_t *cr, double *x, double *y, bool odd_integer_line_width = true) { cairo_user_to_device (cr, x, y); if (odd_integer_line_width) { // round to nearest half integer *x = round (*x) + .5; *y = round (*y) + .5; } else { // round to nearest integer *x = round (*x); *y = round (*y); } cairo_device_to_user (cr, x, y); } static double snapx(cairo_t* cr, double ax) { double x = ax; double y = 0; snap_point(cr, &x, &y); return x; } static double snapy(cairo_t* cr, double ay) { double x = 0; double y = ay; snap_point(cr, &x, &y); return y; } static void draw_grid_lines(cairo_t* cr, int maxx, int maxy, int step, double linewidth) { for (int x = 0; x < maxx; x += step) { cairo_move_to (cr, snapx(cr,x), snapy(cr,0)); cairo_line_to (cr, snapx(cr,x), snapy(cr,maxy)); cairo_close_path(cr); } for (int y = 0; y < maxy; y += step) { cairo_move_to (cr, snapx(cr,0), snapy(cr,y)); cairo_line_to (cr, snapx(cr,maxx), snapy(cr,y)); cairo_close_path(cr); } //cairo_set_source_rgb(cr, 0.84, 0.84, 0.84); //paper color: Dim Grey cairo_set_source_rgb(cr, 0.64, 0.64, 0.64); //? cairo_save(cr); { cairo_identity_matrix (cr); cairo_set_line_width (cr, linewidth); cairo_stroke (cr); } cairo_restore(cr); } static void draw_grid(cairo_t* cr, int pw, int ph, int zoom) { cairo_save(cr); { // line positions in mm if (0 < zoom && zoom <= 100) { draw_grid_lines(cr, pw, ph, 1000, .2); } else if (100 < zoom && zoom <= 250) { draw_grid_lines(cr, pw, ph, 1000, .2); } else if (250 < zoom) { draw_grid_lines(cr, pw, ph, 500, .2); draw_grid_lines(cr, pw, ph, 1000, .4); } } cairo_restore(cr); } static void draw_paper(cairo_t* cr, double sf, int pw, int ph) { double shadow = 3.0 / sf; cairo_save(cr); { cairo_rectangle (cr, shadow, shadow, pw, ph); cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); cairo_fill(cr); cairo_rectangle (cr, 0, 0, pw, ph); cairo_set_source_rgb(cr, 0.84, 0.84, 0.84); //Dim Grey cairo_fill(cr); } cairo_restore(cr); } PAINTSTRUCT ps; HDC hdc; void dopainting(HDC hdc) { cairo_t *cr = cairo_create(cairo_win32_surface_create( hdc )); // dark gray background cairo_set_source_rgb(cr, 0.5, 0.5, 0.5); cairo_paint(cr); draw_paper(cr, 1.0, 500, 500); draw_grid(cr, 500, 500, 100); cairo_destroy(cr); } /* This function is called by the Windows function DispatchMessage() */ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) /* handle the messages */ { case WM_DESTROY: PostQuitMessage (0); /* send a WM_QUIT to the message queue */ break; case WM_PAINT: hdc = BeginPaint(hwnd, &ps); dopainting(hdc); EndPaint(hwnd, &ps); ValidateRect(hwnd, NULL); break; default: /* for messages that we don't deal with */ return DefWindowProc (hwnd, message, wParam, lParam); } return 0; } -- Regards, Hakki Dogusan -- cairo mailing list [email protected] http://lists.cairographics.org/mailman/listinfo/cairo