Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread 'main' panicked #853

Open
yanschor opened this issue Dec 6, 2024 · 2 comments
Open

Thread 'main' panicked #853

yanschor opened this issue Dec 6, 2024 · 2 comments

Comments

@yanschor
Copy link

yanschor commented Dec 6, 2024

While processing the attached SVG file the process fails with the following error message:

Warning (in usvg::parser::filter:93): Failed to parse a filter value cause expected '(' not '^' at position 2. Skipping.
thread 'main' panicked at crates/resvg/src/main.rs:735:78:
called 'Option::unwrap()' on a 'None' value

Our team discovered the issue during a current research project focusing on the schema-based generation of test-data for different XML specifications.

Steps to Reproduce

  1. Execute resvg <filepath> test.png

Environment:

• OS: macOS 15.1.1

• reSVG version: 0.44.0

SVG File:

<?xml version="1.0" encoding="UTF-16"?>
<tg:svg xmlns:tg="http://www.w3.org/2000/svg" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="id0" xml:base="Dw" class=" &#167;"
    color="navy" color-interpolation="auto" color-rendering="optimizeQuality" fill="	"
    stroke-dasharray="" font-family="&#xEEe2;&#xeE95;&#x18093;" font-size-adjust="none"
    font-stretch="extra-expanded" font-variant="normal" cursor="s-resize" display="compact"
    filter="B^" pointer-events="all" shape-rendering="auto" visibility="inherit" color-profile=""
    marker-mid="#" alignment-baseline="inherit" direction="inherit"
    glyph-orientation-vertical="+31deg" text-anchor="middle" text-decoration="none"
    unicode-bidi="inherit" word-spacing="exact" writing-mode="rl" overflow="hidden" onfocusin=""
    onclick="&#144;&#xFedE;&#xE66C;


" onmousedown="
" onmouseup="&#x10EF5A;" onmouseover=""
    onload="" onunload="" onabort="
" y="694e2" width="6e8" height="01.e+8"
    contentScriptType="multipartᘢ𩡩ﬤ𤤽𦏮悁" contentStyleType="image">
    <tg:a id="id1" xml:base="^d" xlink:role="&lt;&#38;" xlink:title="" xlink:show="replace"
        xlink:href="z" requiredExtensions="&#xA52Fc;
" externalResourcesRequired="false"
        color-interpolation="linearRGB" flood-color="&#xfBde;&#226;" flood-opacity="" fill=""
        fill-opacity="" stroke-dasharray="" stroke-miterlimit="" color-interpolation-filters="auto"
        font-size-adjust="+.77" font-stretch="ultra-expanded" font-variant="inherit"
        font-weight="300" stop-opacity="" clip-path="~N" clip-rule="inherit" cursor="Ru"
        display="inline-table" filter="~" image-rendering="auto" mask="S[M" visibility="visible"
        lighting-color="&#xed25;" marker-start="none" marker-mid="none" direction="inherit"
        glyph-orientation-vertical="+20rad" clip="inherit" overflow="visible" transform=""
        onfocusout="" onclick="" onmousedown="&#x100Dd0;" onmouseup="&#165;" onmouseover="
"
        onmousemove="" target="&#7758;"></tg:a>
    <tg:polyline id="id2" xml:base="h" requiredExtensions="" xml:lang="" class="


 " style=""
        color="IrGuLz" fill="" fill-opacity="	" fill-rule="nonzero" stroke=""
        stroke-dashoffset="&#x10Eafb;" stroke-linecap="butt" stroke-miterlimit="" clip-path="~DV"
        cursor="/" display="table-footer-xs:group" image-rendering="optimizeQuality"
        text-rendering="geometricPrecision" visibility="inherit" marker-mid="none" marker-end="cF"
        onfocusin="" onmouseover="&#xfBF4;&#201;" onmousemove="" onmouseout="" onload="
"
        points="+06,00  -57,19 ">
        <title id="id4" xml:base="B" xml:lang="x-lZiW0" xml:space="default" class=""
            style="*
&#xF4F0c;
"> </title>
    </tg:polyline>
    <tg:view id="id3" preserveAspectRatio=" none" viewTarget="&#141;">
        <title id="id5" xml:base="~^" xml:lang="zh-min" content="structured text"></title>
    </tg:view>
</tg:svg>
@waywardmonkeys
Copy link
Collaborator

The stack trace here is:

called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:665:5
   1: core::panicking::panic_fmt
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/panicking.rs:74:14
   2: core::panicking::panic
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/panicking.rs:148:5
   3: core::option::unwrap_failed
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/option.rs:2012:5
   4: core::option::Option<T>::unwrap
             at /.../stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/option.rs:972:21
   5: resvg::render_svg
             at ./crates/resvg/src/main.rs:734:26
   6: resvg::process
             at ./crates/resvg/src/main.rs:103:15
   7: resvg::main
             at ./crates/resvg/src/main.rs:12:21
   8: core::ops::function::FnOnce::call_once
             at /.../stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5

And the code here is:

        let mut pixmap = tiny_skia::Pixmap::new(size.width(), size.height()).unwrap();

And that's because the size is:

[crates/resvg/src/main.rs:734:1] size = IntSize {
    width: 600000000,
    height: 100000000,
}

@waywardmonkeys
Copy link
Collaborator

The file is requesting something of that size:

width="6e8" height="01.e+8"

So no real surprise ...

This seems like it is the same as the comment from @RazrFalcon in #815 about limiting the maximum pixmap size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants