Re: [Inkscape-devel] [PATCH] terminate called after throwing an instance of std::length_error
Hi Adrian!
Thank you for the patch. I have taken care of the bug reports as it did turn out to be a duplicate report issue. It appears that the issue in the reports is actually library related, as I can not reproduce it with a newer distribution (Ubuntu Intrepid) and the 0.46 release.
I have attached the patch you supplied to the bug report so it can be tested against Ubuntu Hardy to see if it is fixed there (as that generation of distro seems to exhibit the problem). Thanks again, and know that if you want to submit more patches or contribute in any other way, it's always appreciated. :)
Cheers, Josh
Adrian Knoth wrote:
[Note: I've already sent this yesterday, but the mail didn't make it through until now, so I resend it with inline patch and without quotes in the subject]
[Note2; Yesterday, I tested against NULL, but changed this to 0 in order to avoid the notion of a pointer.]
Hi!
Sorry for not posting to launchpad, I don't want to register all the time. I'm talking about
https://bugs.launchpad.net/inkscape/+bug/229412
and
https://bugs.launchpad.net/inkscape/+bug/235383
which are probably the same (duplicate).
I also faced this problem, so I took a closer look. Here's a more detailed backtrace:
Starting program: /tmp/inkscape-0.46/src/inkscape /tmp/mon_01_overall.pdf [Thread debugging using libthread_db enabled] [New Thread 0x7fe1e17eb6f0 (LWP 12419)] terminate called after throwing an instance of 'std::length_error' what(): basic_string::append
Program received signal SIGABRT, Aborted. [Switching to Thread 0x7fe1e17eb6f0 (LWP 12419)] 0x00007fe1d9a26ef5 in raise () from /lib/libc.so.6 (gdb) bt #0 0x00007fe1d9a26ef5 in raise () from /lib/libc.so.6 #1 0x00007fe1d9a28413 in abort () from /lib/libc.so.6 #2 0x00007fe1da4c6244 in __gnu_cxx::__verbose_terminate_handler () from /usr/lib/libstdc++.so.6 #3 0x00007fe1da4c4646 in ?? () from /usr/lib/libstdc++.so.6 #4 0x00007fe1da4c4673 in std::terminate () from /usr/lib/libstdc++.so.6 #5 0x00007fe1da4c475a in __cxa_throw () from /usr/lib/libstdc++.so.6 #6 0x00007fe1da461347 in std::__throw_length_error () from /usr/lib/libstdc++.so.6 #7 0x00007fe1da4a3be0 in std::string::append () from /usr/lib/libstdc++.so.6 #8 0x00007fe1e05dffc2 in Glib::ustring::append (this=0x7fffe9930a20, src=0x3083 <Address 0x3083 out of bounds>, n=18446744073709551615) at ustring.cc:494 #9 0x000000000091f404 in Inkscape::Extension::Internal::SvgBuilder::_flushText (this=0x3733c00) at extension/internal/pdfinput/svg-builder.cpp:1213 #10 0x000000000091fb79 in Inkscape::Extension::Internal::SvgBuilder::endTextObject (this=0x3083, state=0x3083) at extension/internal/pdfinput/svg-builder.cpp:1317 #11 0x0000000000923b99 in PdfParser::go (this=0x3733dc0, topLevel=<value optimized out>) at extension/internal/pdfinput/pdf-parser.cpp:410 #12 0x0000000000927413 in PdfParser::parse (this=0x3733dc0, obj=0x7fffe9930da0, topLevel=1) at extension/internal/pdfinput/pdf-parser.cpp:381 #13 0x0000000000901653 in Inkscape::Extension::Internal::PdfInput::open ( this=<value optimized out>, uri=<value optimized out>) at extension/internal/pdfinput/pdf-input.cpp:704 #14 0x00000000008de5e1 in Inkscape::Extension::Input::open (this=0x2d58ea0, uri=0x35caad8 "/tmp/mon_01_overall.pdf") at extension/input.cpp:156 #15 0x00000000008dd9dd in Inkscape::Extension::open ( key=<value optimized out>, filename=0x35caad8 "/tmp/mon_01_overall.pdf") at extension/system.cpp:92 #16 0x0000000000458899 in sp_file_open (uri=@0x7fffe9930f00, key=0x0, add_to_recent=true, replace_empty=true) at file.cpp:181 #17 0x00000000004500ef in sp_main_gui (argc=2, argv=0x7fffe9931088) at main.cpp:714 #18 0x0000000000450605 in main (argc=2, argv=0x7fffe9931088) at main.cpp:539
Obviously, frame 9 calls text_buffer.append(&glyph.code, 1). It turned out that glyph.code[0] eventually is \0, so glyph.code shorter than 1, hence the exception.
I haven't digged into the code to find out why glyph.code does not always contain a sensible value, but I've added a 0 check.
The attached patch fixes the problem, inkscape can then successfully import the PDFs in question.
Anyway, somebody who's more common with the code should have a look at this, since my patch only cures the symptoms, not the root cause.
HTH
PS: Somebody should probably also update and merge the bug reports ;)
--- src/extension/internal/pdfinput/svg-builder.cpp 2008-03-11 05:20:21.000000000 +0100 +++ src/extension/internal/pdfinput/svg-builder.cpp.adi 2008-09-30 20:07:18.000000000 +0200 @@ -1210,7 +1210,9 @@ last_delta_pos = delta_pos;
// Append the character to the text buffer
text_buffer.append((char *)&glyph.code, 1);
if (0 != glyph.code[0]) {
text_buffer.append((char *)&glyph.code, 1);
} glyphs_in_a_row++; i++;
participants (1)
-
Josh Andler