joewing / jwm

Joe's Window Manager
http://joewing.net/projects/jwm
MIT License
520 stars 84 forks source link

Crash when using a SVG wallpaper without a viewbox #571

Closed dimkr closed 2 years ago

dimkr commented 2 years ago

JWM 2.4.2, librsvg2 2.50.3.

rwidth and rheight remain 0, because the image doesn't specify its dimensions in pixels.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="305mm" height="250mm" version="1.1">
  <defs>
    <linearGradient id="lg1" x1="357" y1="-42" x2="381" y2="870" gradientUnits="userSpaceOnUse">
      <stop style="stop-color:#555" offset="0"/>
      <stop style="stop-color:#CDDEE6" offset="0.9"/>
      <stop style="stop-color:#8CA9B3" offset="1"/>
    </linearGradient>
    <filter id="f1" x="0" width="1" y="-1" height="2"><feGaussianBlur stdDeviation="7"/></filter>
  </defs>

  <path style="opacity:1;fill:url(#lg1);fill-opacity:1;stroke:none" d="m -19,0 1119,0 0,897 -1124,0 z"/>
  <path style="fill:#769CAC;filter:url(#f1)" d="m 1100,690 -130,10 c -70,-20 -210,-10 -270,0 60,-20 140,-10 270,-20 30,0 130,0 130,-10 z"/>
  <path style="fill:#6C8995;filter:url(#f1)" d="m 540,750 -130,10 c -70,-20 -230,-10 -290,-20 70,0 190,-10 290,0 40,10 160,10 190,10 z"/>

</svg>
<Desktops>
    <Background type="image">/tmp/crash.svg</Background>
</Desktops>
thread '<unnamed>' panicked at 'assertion failed: width > 0 && height > 0', rsvg_internals/src/surface_utils/shared_surface.rs:192:9
stack backtrace:
   0:     0x7f0b335b770c - <unknown>
   1:     0x7f0b3366b8ff - <unknown>
   2:     0x7f0b335ad615 - <unknown>
   3:     0x7f0b335e370d - <unknown>
   4:     0x7f0b335e3413 - <unknown>
   5:     0x7f0b335e3e4f - <unknown>
   6:     0x7f0b331e3194 - <unknown>
   7:     0x7f0b331e316c - <unknown>
   8:     0x7f0b331f6d8c - <unknown>
   9:     0x7f0b3327c322 - <unknown>
  10:     0x7f0b33269f56 - <unknown>
  11:     0x7f0b33272613 - <unknown>
  12:     0x7f0b3328902c - <unknown>
  13:     0x7f0b33163bf1 - <unknown>
  14:     0x7f0b3326ceb2 - <unknown>
  15:     0x7f0b33169582 - <unknown>
  16:     0x7f0b332178ad - <unknown>
  17:     0x7f0b332754a8 - <unknown>
  18:     0x7f0b33217bcf - <unknown>
  19:     0x7f0b331828fd - <unknown>
  20:     0x7f0b3326a227 - <unknown>
  21:     0x7f0b331824ce - <unknown>
  22:     0x7f0b33163c41 - <unknown>
  23:     0x7f0b3326ceb2 - <unknown>
  24:     0x7f0b33169582 - <unknown>
  25:     0x7f0b332178ad - <unknown>
  26:     0x7f0b332754a8 - <unknown>
  27:     0x7f0b332671c1 - <unknown>
  28:     0x7f0b33251ae5 - <unknown>
  29:     0x7f0b331196cb - rsvg_rust_handle_render_document
  30:     0x55949ccf55f1 - LoadSVGImage
                               at /tmp/jwm-2.4.2/src/image.c:535
  31:     0x55949ccf3702 - LoadImage
                               at /tmp/jwm-2.4.2/src/image.c:131
  32:     0x55949ccefa53 - LoadNamedIcon
                               at /tmp/jwm-2.4.2/src/icon.c:312
  33:     0x55949ccadb41 - LoadImageBackground
                               at /tmp/jwm-2.4.2/src/background.c:291
  34:     0x55949ccac78d - StartupBackgrounds
                               at /tmp/jwm-2.4.2/src/background.c:80
  35:     0x55949ccfad34 - Startup
                               at /tmp/jwm-2.4.2/src/main.c:517
  36:     0x55949ccf9a3c - main
                               at /tmp/jwm-2.4.2/src/main.c:192
  37:     0x7f0b3244cd0a - __libc_start_main
  38:     0x55949ccab1da - _start
  39:                0x0 - <unknown>
fatal runtime error: failed to initiate panic, error 5
Aborted

The problem is gone after this patch, which forces the 2.3.7 behavior of calling rsvg_handle_get_dimensions():

#if 0 && LIBRSVG_CHECK_VERSION(2, 46, 0)           <--
   rsvg_handle_get_intrinsic_dimensions(rh, &has_width, &pwidth, &has_height, &pheight,
      &has_viewbox, &viewbox);               
   if(has_width && has_height && pwidth.unit == RSVG_UNIT_PX && pheight.unit == RSVG_UNIT_PX) {             <-- false, size is specified in mm
      dim.width = pwidth.length;             
      dim.height = pheight.length;
   } else if(has_viewbox) {                      <-- false, no viewbox
      dim.width = viewbox.width;                        
      dim.height = viewbox.height;                  
   } else {   
      dim.width = rwidth;                          <- rdwith and rheight are 0                          
      dim.height = rheight;
   }                                                 
#else                       
   rsvg_handle_get_dimensions(rh, &dim);
#endif