Crash program with cairo_recording_surface_create and with big rectangle size

Kęstutis dbtopas at dbtopas.lt
Fri Mar 15 12:28:49 UTC 2024


Hello,

What is the maximum width and height of a rectangle that I can use with 
the recording surface?

When I attempted to use a rectangle with dimensions of 39000x57400, the 
program crashed with a General Protection Fault (GPF) due to an endless 
recursion occurring in the function |bbtree_add| within the module 
|cairo-recording-surface.c|.

I have attached an example of the program.

Could someone please provide assistance with this situation?

Thank you for any insights and best regards.

Kestutis


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20240315/5ab88791/attachment.htm>
-------------- next part --------------
#include <cairo/cairo.h>
#include <cairo/cairo-pdf.h>
#include <stddef.h>

int main( void )
{
  cairo_t             * hC = NULL, * hC2 = NULL; 
  cairo_surface_t     * hRec = NULL, * hRec2 = NULL, * hSurf = NULL;
  cairo_rectangle_t   sRect;
  cairo_matrix_t      sMatrix;

  sRect.x      = 0;
  sRect.y      = 0;
  sRect.width  = 39000.00;   
  sRect.height = 58400.00;  
  hRec = cairo_recording_surface_create( CAIRO_CONTENT_COLOR_ALPHA, &sRect );
  hC = cairo_create( hRec );
  cairo_set_source_rgb( hC, 0, 0, 0 );
  cairo_set_line_width( hC, 30 );

  cairo_save( hC );
  cairo_select_font_face( hC, "Arial", 0, 0 );
  cairo_set_font_size( hC, 352.78 );
  cairo_restore( hC );

  sRect.x      = 0;
  sRect.y      = 0;
  sRect.width  = 39000.00;   
  sRect.height = 57400.00;  
  hRec2 = cairo_recording_surface_create( CAIRO_CONTENT_COLOR_ALPHA, &sRect );
  hC2 = cairo_create( hRec2 );
  cairo_set_source_rgb( hC2, 0, 0, 0 );
  cairo_set_line_width( hC2, 30 );

  cairo_save( hC2 );
  cairo_rectangle( hC2, 400, 200, 3300, 450 );
  cairo_set_source_rgb( hC2, 1, 1, 1 );
  cairo_fill_preserve( hC2 );
  cairo_set_source_rgb( hC2, 0, 0, 0 );
  cairo_clip( hC2 );
  cairo_select_font_face( hC2, "Courier New", 0, 0);
  cairo_set_font_size( hC2, 246.94);
  cairo_move_to( hC2, 374.00, 390.00 );
  cairo_show_text( hC2, "Some text" );
  cairo_restore( hC2 );

  cairo_save( hC );
  cairo_destroy( hC2 );
  cairo_set_source_surface( hC, hRec2, 0, 0 );
  cairo_paint( hC );
  cairo_surface_destroy( hRec2 );
  cairo_restore( hC );

  cairo_select_font_face(hC,"Arial", 0, 0 );
  cairo_set_font_size( hC, 211.67);
  cairo_move_to( hC, 32608.00, 57596.00);
  cairo_show_text( hC , "Footer text" );
  cairo_stroke( hC );
  cairo_destroy( hC );

  hSurf = cairo_pdf_surface_create( "test.pdf",  2 * 210 * 72 / 25.40,  2 * 297 * 72 / 25.40);
  hC = cairo_create( hSurf );
  sMatrix.xx = 0.0491;
  sMatrix.yx = 0;
  sMatrix.xy = 0;
  sMatrix.yy = 0.05;
  sMatrix.x0 = 98.27;
  sMatrix.y0 = 49.13;
  cairo_transform( hC, &sMatrix );
  cairo_set_source_surface( hC, hRec, 0, 0);
  cairo_paint( hC );
  cairo_destroy( hC );
  cairo_surface_destroy( hSurf );
  cairo_surface_destroy( hRec );
  
  return 0;
}


More information about the cairo mailing list