Crash when copying item to clipboard, with example

Summary:

When copying the rectangle (see minimal example attached below) to the clipboard Inkscape consumed 100% CPU for some time, then crashes.

Steps to reproduce:

  • Save both files attached to this ticket.
  • Open main.svg in Inkscape
  • Select the black rectangle
  • Copy the rectangle to the clipboard using Ctrl-C or Ctrl-X

main.svg other.svg

What happened?

When the item is copied, Inkscape consumes 100% CPU and crashes afterwards.

The issue has to be related to the group name "g1", renaming this to something else seem to avoid the crash. Even though this group is not referenced in the main document.

#6  0x00007ffff54e0fae in GC_malloc_kind () at /lib64/libgc.so.1
#7  0x00007ffff5ea8c58 in Inkscape::GC::Core::malloc_atomic (size=1) at inkscape/src/inkgc/gc-core.h:69
#8  operator new (size=size@entry=24, scan=scan@entry=Inkscape::GC::ATOMIC, collect=collect@entry=Inkscape::GC::AUTO, cleanup=cleanup@entry=0x0, data=data@entry=0x0) at inkscape/src/inkgc/gc-core.h:141
#9  0x00007ffff6954cd0 in operator new[] (size=24, scan=Inkscape::GC::ATOMIC, collect=Inkscape::GC::AUTO, cleanup=0x0, data=0x0) at inkscape/src/inkgc/gc-core.h:173
#10 operator new[] (size=24, scan=Inkscape::GC::ATOMIC, cleanup=0x0, data=0x0) at inkscape/src/inkgc/gc-core.h:181
#11 Inkscape::Util::share_string (string=string@entry=0x694f4450 "0 0 3368.2136 2973.2764", length=23) at inkscape/src/util/share.cpp:27
#12 0x00007ffff6954d22 in Inkscape::Util::share_string (string=string@entry=0x694f4450 "0 0 3368.2136 2973.2764") at inkscape/src/util/share.cpp:22
#13 0x00007ffff66da2f0 in Inkscape::XML::SimpleNode::setAttributeImpl (this=0x7fff9a6b8b40, name=<optimized out>, value=<optimized out>) at inkscape/src/xml/simple-node.cpp:376
#14 0x00007ffff66cff89 in Inkscape::XML::Node::setAttribute (this=this@entry=0x7fff9a6b8c48, key=..., key@entry=..., value=...) at inkscape/src/xml/node.cpp:27
#15 0x00007ffff66d3685 in sp_repr_svg_read_node (xml_doc=xml_doc@entry=0x7fff9a6b4b08, node=node@entry=0x69479ba0, default_ns=default_ns@entry=0x7ffff7738022 "http://www.w3.org/2000/svg", prefix_map=std::map with 2 elements = {...})
    at inkscape/src/util/const_char_ptr.h:30
#16 0x00007ffff66d37bb in sp_repr_do_read (doc=doc@ent![main.svg](/uploads/b3efe41e0f22ef15e20f4b4b8ee85b60/main.svg)![other.svg](/uploads/0299c68aa6251f1337efbbc2608b4103/other.svg)ry=0x3209700, default_ns=default_ns@entry=0x7ffff7738022 "http://www.w3.org/2000/svg") at inkscape/src/xml/repr-io.cpp:453
#17 0x00007ffff66d3baf in sp_repr_read_file (filename=filename@entry=0x694f3df0 "<redacted>/other.svg", default_ns=default_ns@entry=0x7ffff7738022 "http://www.w3.org/2000/svg", xinclude=xinclude@entry=false)
    at inkscape/src/xml/repr-io.cpp:307
#18 0x00007ffff6730342 in SPDocument::createNewDoc (filename=0x694f3df0 "<redacted>/other.svg", keepalive=keepalive@entry=false, make_new=make_new@entry=false, parent=parent@entry=0x7fff9e399c00)
    at /mnt/space/inkscape/src/document.cpp:687
#19 0x00007ffff6730633 in SPDocument::createChildDoc (this=this@entry=0x7fff9e399c00, filename="<redacted>/other.svg") at /usr/include/c++/14/bits/basic_string.h:227
The backtrace goes on for a lot longer. I can provide more when needed.

Version info

Reproduced with custom built Inkscape version from master (f7a01b6a), but also happened on the 1.4.x branch.

Linux: Fedora 41

Inkscape 1.5-dev (096c0f9c4e, 2025-01-05)

                      Compile  (Run)
    GLib version:     2.82.2
    GTK version:      4.17.2 (4.17.2)
    glibmm version:   2.78.1
    gtkmm version:    4.14.0
    libxml2 version:  2.12.9
    libxslt version:  1.1.42
    Cairo version:    1.18.2 (1.18.2)
    Pango version:    1.54.0 (1.56.0)
    HarfBuzz version: 9.0.0 (9.0.0)
    Poppler version:  24.08.0

    OS version:       Fedora Linux 41 (Forty One)
Edited by Rainer Keller