Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • librsvg librsvg
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 190
    • Issues 190
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 6
    • Merge requests 6
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOME
  • librsvglibrsvg
  • Issues
  • #187

Closed
Open
Created Jan 21, 2018 by nezumisama@nezumisama

Abort in rsvg with 'Cairo error "invalid matrix (not invertible)"' when trying to render certain broken svgs

When I try to render an svg file like this with rsvg (versions 2.41.0-2.42.0):

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     width="10" height="10">
  <defs>
    <linearGradient id="grad"/>
    <g id="path">
      <path d=""/>
    </g>
  </defs>
  <g>
    <use style="fill:url(#grad)" xlink:href="#path"/>
  </g>
</svg>

I get:

% rsvg-convert error_empty_path.svg -o error_empty_path.png    
thread '<unnamed>' panicked at 'Cairo error "invalid matrix (not invertible)"', /build/.cargo/registry/src/github.com-1ecc6299db9ec823/cairo-sys-rs-0.5.0/src/enums.rs:75:12
note: Run with `RUST_BACKTRACE=1` for a backtrace.
fatal runtime error: failed to initiate panic, error 5
zsh: abort (core dumped)  rsvg-convert error_empty_path.svg -o error_empty_path.png

The same happens, when the path is a degenerate triangle:

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     width="10" height="10">
  <defs>
    <linearGradient id="grad"/>
    <g id="path">
      <path d="M0,0L1,1L2,2Z"/>
    </g>
  </defs>
  <g>
    <use style="fill:url(#grad)" xlink:href="#path"/>
  </g>
</svg>

gives:

% rsvg-convert error_not_triangle.svg -o error_not_triangle.png
thread '<unnamed>' panicked at 'Cairo error "invalid matrix (not invertible)"', /build/.cargo/registry/src/github.com-1ecc6299db9ec823/cairo-sys-rs-0.5.0/src/enums.rs:75:12
note: Run with `RUST_BACKTRACE=1` for a backtrace.
fatal runtime error: failed to initiate panic, error 5
zsh: abort (core dumped)  rsvg-convert error_not_triangle.svg -o error_not_triangle.png

However, when the path is a proper triangle:

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     width="10" height="10">
  <defs>
    <linearGradient id="grad"/>
    <g id="path">
      <path d="M0,0L1,1L1,2Z"/>
    </g>
  </defs>
  <g>
    <use style="fill:url(#grad)" xlink:href="#path"/>
  </g>
</svg>

no error is shown.

Version 2.40.20 doesn't have such issue (yielding empty 10x10 pngs in all cases).

I stumbled across this issue because an SVG icon set (ACYLS) contains such broken SVGs and it causes programs, that try to display those icons to fail with the above abort.

Now, I know those SVG files are broken and wouldn't render anything useful anyway, but I think the library shouldn't abort, and with a cryptic message (the message doesn't indicate the cause of the problem and it took me a while to find that cause). What I'd expect ideally is for the library to return an empty image and display a warning in the console, and allow the application to continue.

All 3 minimal example files are attached. Please be weary that if you have librsvg between 2.41.0-2.42.0 installed, these files can kill any program that will try to render them (I had firefox crash when I tried to attach them here for this reason). error_empty_path.svg error_not_triangle.svg ok.svg

Assignee
Assign to
Time tracking