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

Godot crashes when importing a certain SVG icon with embedded PNG images #91781

Closed
nongvantinh opened this issue May 10, 2024 · 5 comments · Fixed by #93655
Closed

Godot crashes when importing a certain SVG icon with embedded PNG images #91781

nongvantinh opened this issue May 10, 2024 · 5 comments · Fixed by #93655

Comments

@nongvantinh
Copy link
Contributor

Tested versions

Godot Engine v4.2.stable.official.46dc27791 also happens with mono version

System information

Windows 11

Issue description

Godot crashes when importing a certain SVG icon

Steps to reproduce

Simply place this file somewhere in the project folder and return to the editor. Godot will attempt to import the file and crash.
SpikedBulletIcon

Minimal reproduction project (MRP)

If you don’t want to create a minimal reproducible project (MRP) yourself, you can use mine.
godot-crash.zip

@matheusmdx
Copy link
Contributor

Here the backtrace using a debug version:

================================================================
CrashHandlerException: Program crashed
Engine version: Godot Engine v4.3.dev.custom_build (4577dfdb6747600438ac4b86c29a4d6c12ec9b0a)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[0] _apply (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\sw_engine\tvgSwRasterTexmap.h:1054)
[1] _apply (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\sw_engine\tvgSwRasterTexmap.h:1054)
[2] _rasterTexmapPolygon (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\sw_engine\tvgSwRasterTexmap.h:1141)
[3] _rasterImage (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\sw_engine\tvgSwRaster.cpp:1421)
[4] rasterImage (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\sw_engine\tvgSwRaster.cpp:1936)
[5] tvg::SwRenderer::renderImage (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\sw_engine\tvgSwRenderer.cpp:491)
[6] tvg::Picture::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgPicture.cpp:75)
[7] tvg::Paint::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgPaint.cpp:224)
[8] tvg::Scene::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgScene.h:151)
[9] tvg::Paint::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgPaint.cpp:224)
[10] tvg::Scene::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgScene.h:151)
[11] tvg::Paint::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgPaint.cpp:224)
[12] tvg::Scene::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgScene.h:151)
[13] tvg::Paint::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgPaint.cpp:224)
[14] tvg::Scene::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgScene.h:151)
[15] tvg::Paint::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgPaint.cpp:224)
[16] tvg::Scene::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgScene.h:151)
[17] tvg::Paint::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgPaint.cpp:224)
[18] tvg::Scene::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgScene.h:151)
[19] tvg::Paint::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgPaint.cpp:224)
[20] tvg::Scene::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgScene.h:151)
[21] tvg::Paint::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgPaint.cpp:224)
[22] tvg::Scene::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgScene.h:151)
[23] tvg::Paint::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgPaint.cpp:224)
[24] tvg::Picture::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgPicture.cpp:82)
[25] tvg::Paint::Impl::render (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgPaint.cpp:224)
[26] tvg::Canvas::Impl::draw (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgCanvas.h:120)
[27] tvg::Canvas::draw (C:\Users\Matheus\Downloads\Godot Source Git\godot\thirdparty\thorvg\src\renderer\tvgCanvas.cpp:67)
[28] ImageLoaderSVG::create_image_from_utf8_buffer (C:\Users\Matheus\Downloads\Godot Source Git\godot\modules\svg\image_loader_svg.cpp:122)
[29] ImageLoaderSVG::create_image_from_utf8_buffer (C:\Users\Matheus\Downloads\Godot Source Git\godot\modules\svg\image_loader_svg.cpp:156)
[30] ImageLoaderSVG::create_image_from_string (C:\Users\Matheus\Downloads\Godot Source Git\godot\modules\svg\image_loader_svg.cpp:168)
[31] ImageLoaderSVG::load_image (C:\Users\Matheus\Downloads\Godot Source Git\godot\modules\svg\image_loader_svg.cpp:182)[32] ImageLoader::load_image (C:\Users\Matheus\Downloads\Godot Source Git\godot\core\io\image_loader.cpp:99)
[33] ResourceImporterTexture::import (C:\Users\Matheus\Downloads\Godot Source Git\godot\editor\import\resource_importer_texture.cpp:490)
[34] EditorFileSystem::_reimport_file (C:\Users\Matheus\Downloads\Godot Source Git\godot\editor\editor_file_system.cpp:2132)
[35] EditorFileSystem::reimport_files (C:\Users\Matheus\Downloads\Godot Source Git\godot\editor\editor_file_system.cpp:2374)
[36] EditorFileSystem::_update_scan_actions (C:\Users\Matheus\Downloads\Godot Source Git\godot\editor\editor_file_system.cpp:701)
[37] EditorFileSystem::_notification (C:\Users\Matheus\Downloads\Godot Source Git\godot\editor\editor_file_system.cpp:1299)
[38] EditorFileSystem::_notificationv (C:\Users\Matheus\Downloads\Godot Source Git\godot\editor\editor_file_system.h:146)
[39] Object::notification (C:\Users\Matheus\Downloads\Godot Source Git\godot\core\object\object.cpp:840)
[40] SceneTree::_process_group (C:\Users\Matheus\Downloads\Godot Source Git\godot\scene\main\scene_tree.cpp:954)
[41] SceneTree::_process (C:\Users\Matheus\Downloads\Godot Source Git\godot\scene\main\scene_tree.cpp:1031)
[42] SceneTree::process (C:\Users\Matheus\Downloads\Godot Source Git\godot\scene\main\scene_tree.cpp:510)
[43] Main::iteration (C:\Users\Matheus\Downloads\Godot Source Git\godot\main\main.cpp:3814)
[44] OS_Windows::run (C:\Users\Matheus\Downloads\Godot Source Git\godot\platform\windows\os_windows.cpp:1476)
[45] widechar_main (C:\Users\Matheus\Downloads\Godot Source Git\godot\platform\windows\godot_windows.cpp:182)
[46] _main (C:\Users\Matheus\Downloads\Godot Source Git\godot\platform\windows\godot_windows.cpp:204)
[47] main (C:\Users\Matheus\Downloads\Godot Source Git\godot\platform\windows\godot_windows.cpp:218)
[48] WinMain (C:\Users\Matheus\Downloads\Godot Source Git\godot\platform\windows\godot_windows.cpp:232)
[49] __scrt_common_main_seh (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[50] <couldn't map PC to fn name>
-- END OF BACKTRACE --
================================================================

@akien-mga
Copy link
Member

akien-mga commented May 10, 2024

I can confirm the crash, and it's still reproducible in latest thorvg 0.13.3 (as of #91788).

Full gdb backtrace with thorvg 0.13.3:

Thread 1 "godot-git" received signal SIGSEGV, Segmentation fault.
0x000000000710502d in _apply (surface=0x7fff90003170, aaSpans=0x15278280) at thirdparty/thorvg/src/renderer/sw_engine/tvgSwRasterTexmap.h:1054
1054                    *dst = INTERPOLATE(*dst, pixel, line->coverage[0] * pos);

(gdb) bt
#0  0x000000000710502d in _apply (surface=0x7fff90003170, aaSpans=0x15278280) at thirdparty/thorvg/src/renderer/sw_engine/tvgSwRasterTexmap.h:1054
#1  0x00000000071055e3 in _rasterTexmapPolygon (surface=0x7fff90003170, image=0x1f02fb38, transform=0xbbbf110, region=0x0, opacity=255 '\377')
    at thirdparty/thorvg/src/renderer/sw_engine/tvgSwRasterTexmap.h:1140
#2  0x000000000710a884 in _rasterImage (surface=0x7fff90003170, image=0x1f02fb38, transform=0xbbbf110, region=..., opacity=255 '\377') at thirdparty/thorvg/src/renderer/sw_engine/tvgSwRaster.cpp:1421
#3  0x000000000710b586 in rasterImage (surface=0x7fff90003170, image=0x1f02fb38, mesh=0x7fff5c002308, transform=0xbbbf110, bbox=..., opacity=255 '\377')
    at thirdparty/thorvg/src/renderer/sw_engine/tvgSwRaster.cpp:1940
#4  0x000000000710f551 in tvg::SwRenderer::renderImage (this=0x7fff90003200, data=0x1f02fa70) at thirdparty/thorvg/src/renderer/sw_engine/tvgSwRenderer.cpp:487
#5  0x00000000070f5a54 in tvg::Picture::Impl::render (this=0x7fff5c0022e0, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgPicture.cpp:75
#6  0x00000000070f1996 in tvg::Paint::Impl::render (this=0x7fff5c0a2a70, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgPaint.cpp:219
#7  0x00000000070f4604 in tvg::Scene::Impl::render (this=0x7fff5c0ddd30, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgScene.h:139
#8  0x00000000070f1977 in tvg::Paint::Impl::render (this=0x7fff5c093e70, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgPaint.cpp:219
#9  0x00000000070f4604 in tvg::Scene::Impl::render (this=0x7fff5c0ddcb0, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgScene.h:139
#10 0x00000000070f1977 in tvg::Paint::Impl::render (this=0x7fff5c09cf60, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgPaint.cpp:219
#11 0x00000000070f4604 in tvg::Scene::Impl::render (this=0x7fff5c0cc3f0, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgScene.h:139
#12 0x00000000070f1977 in tvg::Paint::Impl::render (this=0x7fff5c01f5c0, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgPaint.cpp:219
#13 0x00000000070f4604 in tvg::Scene::Impl::render (this=0x21208780, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgScene.h:139
#14 0x00000000070f1977 in tvg::Paint::Impl::render (this=0x7fff5c0987d0, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgPaint.cpp:219
#15 0x00000000070f4604 in tvg::Scene::Impl::render (this=0x19bc5430, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgScene.h:139
#16 0x00000000070f1977 in tvg::Paint::Impl::render (this=0x7fff5c08be50, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgPaint.cpp:219
#17 0x00000000070f4604 in tvg::Scene::Impl::render (this=0x2032b390, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgScene.h:139
#18 0x00000000070f1977 in tvg::Paint::Impl::render (this=0x7fff5c084000, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgPaint.cpp:219
#19 0x00000000070f4604 in tvg::Scene::Impl::render (this=0x7fff5c0db220, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgScene.h:139
#20 0x00000000070f1977 in tvg::Paint::Impl::render (this=0x7fff5c08a8b0, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgPaint.cpp:219
#21 0x00000000070f4604 in tvg::Scene::Impl::render (this=0x7fff5c0db660, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgScene.h:139
--Type <RET> for more, q to quit, c to continue without paging--
#22 0x00000000070f1977 in tvg::Paint::Impl::render (this=0x7fff5c0730c0, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgPaint.cpp:219
#23 0x00000000070f5b22 in tvg::Picture::Impl::render (this=0x202ee8c0, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgPicture.cpp:82
#24 0x00000000070f1996 in tvg::Paint::Impl::render (this=0x1ea941b0, renderer=0x7fff90003200) at thirdparty/thorvg/src/renderer/tvgPaint.cpp:219
#25 0x00000000070edf6d in tvg::Canvas::Impl::draw (this=0x1f263370) at thirdparty/thorvg/src/renderer/tvgCanvas.h:118
#26 0x00000000070ed856 in tvg::Canvas::draw (this=0x16403f70) at thirdparty/thorvg/src/renderer/tvgCanvas.cpp:67
#27 0x0000000007119662 in ImageLoaderSVG::create_image_from_utf8_buffer (p_image=..., 
    p_buffer=0x23cd4930 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 5"..., p_buffer_size=36294, p_scale=1, p_upsample=false) at modules/svg/image_loader_svg.cpp:122
#28 0x0000000007119963 in ImageLoaderSVG::create_image_from_utf8_buffer (p_image=..., p_buffer=..., p_scale=1, p_upsample=false) at modules/svg/image_loader_svg.cpp:156
#29 0x0000000007119a9a in ImageLoaderSVG::create_image_from_string (p_image=..., p_string=..., p_scale=1, p_upsample=false, p_color_map=...) at modules/svg/image_loader_svg.cpp:168
#30 0x0000000007119d3c in ImageLoaderSVG::load_image (this=0xcf17810, p_image=..., p_fileaccess=..., p_flags=..., p_scale=1) at modules/svg/image_loader_svg.cpp:190
#31 0x000000000a60a846 in ImageLoader::load_image (p_file=..., p_image=..., p_custom=..., p_flags=..., p_scale=1) at ./core/io/image_loader.cpp:99
#32 0x0000000007d3a6c2 in ResourceImporterTexture::import (this=0x7fff5c00e600, p_source_file=..., p_save_path=..., p_options=..., r_platform_variants=0x7fffffffbf10, r_gen_files=0x7fffffffbf08, 
    r_metadata=0x7fffffffbef0) at ./editor/import/resource_importer_texture.cpp:490
#33 0x00000000076a61b8 in EditorFileSystem::_reimport_file (this=0xd23d5e0, p_file=..., p_custom_options=..., p_custom_importer=..., p_generator_parameters=0x0) at ./editor/editor_file_system.cpp:2160
#34 0x00000000076a8d59 in EditorFileSystem::reimport_files (this=0xd23d5e0, p_files=...) at ./editor/editor_file_system.cpp:2405
#35 0x000000000769b913 in EditorFileSystem::_update_scan_actions (this=0xd23d5e0) at ./editor/editor_file_system.cpp:696
#36 0x000000000769f280 in EditorFileSystem::_notification (this=0xd23d5e0, p_what=17) at ./editor/editor_file_system.cpp:1294
#37 0x000000000773b636 in EditorFileSystem::_notificationv (this=0xd23d5e0, p_notification=17, p_reversed=false) at ./editor/editor_file_system.h:138
#38 0x000000000aabfc52 in Object::notification (this=0xd23d5e0, p_notification=17, p_reversed=false) at ./core/object/object.cpp:904
#39 0x00000000086076e4 in SceneTree::_process_group (this=0xd16aed0, p_group=0xd16b128, p_physics=false) at ./scene/main/scene_tree.cpp:963
#40 0x0000000008607c5d in SceneTree::_process (this=0xd16aed0, p_physics=false) at ./scene/main/scene_tree.cpp:1040
#41 0x0000000008605c7f in SceneTree::process (this=0xd16aed0, p_time=0.13004099999999985) at ./scene/main/scene_tree.cpp:527
#42 0x0000000005b5bbeb in Main::iteration () at main/main.cpp:4053
--Type <RET> for more, q to quit, c to continue without paging--
#43 0x0000000005aa55a4 in OS_LinuxBSD::run (this=0x7fffffffd0d0) at platform/linuxbsd/os_linuxbsd.cpp:962
#44 0x0000000005a9e331 in main (argc=2, argv=0x7fffffffd728) at platform/linuxbsd/godot_linuxbsd.cpp:85

I'm not sure how to reproduce it minimally to file a bug report upstream, maybe @capnm @hermet @mgrudzinska can advise.

I tested upstream svg2png and svg2tvg and they seem to handle it fine.

On the other hand I tested https://thorvg.github.io/thorvg.viewer/ and it seems to fail handling that file, with this error:

Uncaught (in promise) RuntimeError: indirect call signature mismatch
    anonymous https://thorvg.github.io/thorvg.viewer/lottie-player.js line 1 > Function:8
    get https://thorvg.github.io/thorvg.viewer/lottie-player.js:1
    get https://thorvg.github.io/thorvg.viewer/lottie-player.js:1
    createTabs https://thorvg.github.io/thorvg.viewer/main.js:58
    onload https://thorvg.github.io/thorvg.viewer/main.js:229
    loadFile https://thorvg.github.io/thorvg.viewer/main.js:224
    fileDropOrBrowseHandle https://thorvg.github.io/thorvg.viewer/main.js:196
    initialize https://thorvg.github.io/thorvg.viewer/main.js:136
    initialize https://thorvg.github.io/thorvg.viewer/main.js:135
    onload https://thorvg.github.io/thorvg.viewer/main.js:49
    EventHandlerNonNull* https://thorvg.github.io/thorvg.viewer/main.js:45

@akien-mga akien-mga changed the title Godot crashes when importing a certain SVG icon Godot crashes when importing a certain SVG icon with embedded PNG images May 10, 2024
@akien-mga
Copy link
Member

Removing the embedded PNG images from the file (by manually editing it) seems to solve the crash.

@mgrudzinska
Copy link

mgrudzinska commented May 15, 2024

I'm not sure how to reproduce it minimally to file a bug report upstream, maybe @capnm @hermet @mgrudzinska can advise.

I tested upstream svg2png and svg2tvg and they seem to handle it fine.

To reproduce the crash, one needs to use the mesh. Neither svg2png nor svg2tvg use it. If we load the image into the example Texmap.cpp, we reproduce the crash immediately.

@hermet
Copy link

hermet commented May 24, 2024

@nongvantinh @akien-mga the crash issue will be fixed in thorvg v0.13.5. Thanks

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

Successfully merging a pull request may close this issue.

5 participants