Crash on bad character in symbol library title

Bug #1627551 reported by Krzysztof Blachnicki
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Confirmed
Undecided
Unassigned

Bug Description

Sysinfo:
Windows 7 64 bit
Inkscape 0.91 r13725

Steps to reproduce:
1. Create some symbol library.
2. Save it to symbol library directory and set title of saved file to "Podstawowe kształty"
3. Close all instances of Inkscape

And now two ways of causing the crash:
4a. Open any SVG file (i.e. run Inkscape with filename as first argument)
4b. Open Inkscape (without any args), open symbol library and switch to the saved library (the combobox where you choose it will have placeholder symbol in the place where "ł" should be)

The bug itself is composed of two problems. One is crashing when incorrect symbol is given. Second one is saving local characters. File itself is saved as Unicode, yet the name I provide in "title" field in save dialog is "Podstawowe kształty", but it's saved as "Podstawowe kszta?ty" (where "?" is 0xB3). I attached the file which casused the crash.

When I manually open file as raw text and I'll fix the name (the content of the tag <title> - wrongly encoded local character - "ł"), it don't crash anymore and I can use symbol library.

Besides fixing character encoding in title field, I think Inkscape should fail more gracefully, e.g. don't load such library at all.

Revision history for this message
Krzysztof Blachnicki (krzysiunet) wrote :
Revision history for this message
Alvin Penner (apenner) wrote :

crash confirmed on Windows 10, Inkscape 0.91 r13725 (Jan 30 2015)

- copy file crashy.svg to the folder C:\Program Files (x86)\Inkscape\share\symbols
- open Inkscape from DOS
- open Symbols dialog using menu Object->Symbols
- close Inkscape
- this leads to the following error messages

C:\Program Files (x86)\Inkscape>inkscape

(inkscape.exe:11044): GLib-CRITICAL **: g_convert: assertion `str != NULL' failed
(inkscape.exe:11044): GLib-CRITICAL **: g_convert: assertion `str != NULL' failed
(inkscape.exe:11044): GLib-CRITICAL **: g_convert: assertion `str != NULL' failed
(inkscape.exe:11044): GLib-CRITICAL **: g_convert: assertion `str != NULL' failed
(inkscape.exe:11044): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()
(inkscape.exe:11044): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()
(inkscape.exe:11044): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()
C:\Program Files (x86)\Inkscape\share\symbols\crashy.svg:21: parser error : Input is not proper UTF-8, indicate encoding !
Bytes: 0xB3 0x74 0x79 0x3C
     id="title4371">Podstawowe kszta│ty</title>

....................................................................

- second trial, with crashy.svg still in symbols folder
- open Inkscape from DOS
- open Symbols dialog using menu Object->Symbols
- in symbols dialog, click on the dropdown box and click on 'podstawowe'
- get multiple messages of the following type, followed by a crash

(inkscape.exe:12140): GLib-CRITICAL **: g_convert: assertion `str != NULL' failed
...
(inkscape.exe:12140): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()
...
(inkscape.exe:12140): GLib-CRITICAL **: g_convert: assertion `str != NULL' failed
...
(inkscape.exe:12140): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()
...
(inkscape.exe:12140): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()
...

Changed in inkscape:
status: New → Confirmed
Revision history for this message
Alvin Penner (apenner) wrote :

on Windows XP, Inkscape 0.92pre1 (Sep 24 2016) (0.92.x branch)
I get the backtrace:

Program received signal SIGSEGV, Segmentation fault.
0x77c47740 in strcmp () from C:\WINDOWS\system32\msvcrt.dll
(gdb) bt
#0 0x77c47740 in strcmp () from C:\WINDOWS\system32\msvcrt.dll
#1 0x68616ad1 in g_utf8_collate ()
   from C:\InkscapeBZR\inkscape\libglib-2.0-0.dll
#2 0x00c46082 in Inkscape::UI::Dialog::SymbolsDialog::rebuild ()
#3 0x0918f81c in ?? ()
#4 0x0023f350 in ?? ()
#5 0x65c419ef in g_mutex_unlock_win32_cs_impl ()
   from C:\InkscapeBZR\inkscape\libgthread-2.0-0.dll
#6 0x6f776174 in ?? ()
#7 0x6b206577 in ?? ()
#8 0x61747a73 in ?? ()
#9 0x007974b3 in Path::Outline ()
#10 0x00070002 in ?? ()

Revision history for this message
Patrick Storz (ede123) wrote :

I can't reproduce this issue on Windows 10 x64.
- Tested with release versions 0f 0.91.1, 0.92, and 0.92.1 (32-bit) and 0.92.1 (64-bit)

Could it be that you used the wrong encoding for the symbol .svg file?
The file has to be actually encoded as UTF8 (the entry in the XML declaration is not enough!), but then all valid XML characters are allowed.

Revision history for this message
Patrick Storz (ede123) wrote :

Especially watch out for encoding the file as ANSI in your systems codepage as this will allow to store some special characters, that are however not valid UTF8.

Revision history for this message
su_v (suv-lp) wrote :

The steps 1-3 probably describe
* Bug #603442 “UTF characters in the meta-data title field not preserved”
  https://bugs.launchpad.net/inkscape/+bug/603442
* Bug #576126 “[Windows] cannot open file with non-ASCII chars in Save-as Title field”
  https://bugs.launchpad.net/inkscape/+bug/576126

Crash (step 4b, with file from comment 1) reproduced on Windows 10 with
- Inkscape 0.91 (32bit, 64bit, 7z installed into custom location)
- Inkscape 0.92.0, 0.92.1 (32bit, 64bit, 7z installed into custom location)
- Inkscape trunk r15113 (devlibs64)
- Inkscape trunk r15546 (MSYS2)
- Inkscape trunk r15551 (local build with devlibs64)

Revision history for this message
Patrick Storz (ede123) wrote :

> Crash (step 4b, with file from comment 1)

A completely missed that one (shame on me)...
But it's exactly the issue I described: The character in question is not UTF8 encoded but has the encoding of an ANSI codepage (probably Windows-1250 or similar).

The sample file is obviously malformed and it's nothing Inkscape could (or should) handle.
Try the corrected file attached and it should work just fine.

Revision history for this message
Patrick Storz (ede123) wrote :

Regarding steps 1-3:
Yes absolutely right! The title field in the native Windows save dialog is not UTF8 encoded but uses the systems code page... This leads to the wrongly encoded characters in the resulting SVG file as described in bug #576126.

Revision history for this message
Patrick Storz (ede123) wrote :

Actually the native Windows save dialog uses Unicode which is UTF16 on Windows but the result is more or less the same.
I submitted a patch for this part in bug #576126 comment #7.

Revision history for this message
Patrick Storz (ede123) wrote :

Fix for the broken encoding of the title field in Windows native file save dialog commited in revisions
http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/revision/15557
http://bazaar.launchpad.net/~inkscape.dev/inkscape/0.92.x/revision/15397

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.