[Geany] Crash in compare_symbol()

Enrico Tröger enrico.troeger at xxxxx
Tue Jul 31 17:05:10 UTC 2007


On Tue, 31 Jul 2007 03:46:00 -0500, "Jeff Pohlmeyer"
<yetanothergeek at gmail.com> wrote:

> I just ran into a (probably rare) crash bug in Geany.
> 
> If I try to switch Document->Set Encoding from "Unicode->UTF-8"
> to "Without encoding" , then the next time I save the document
> I get a segfault. It looks like it happens when Geany tries to
> rebuild the tags...
> 
> 
> 
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread -1219221808 (LWP 30632)]
> 0xb75d8f91 in strcmp () from /lib/libc.so.6
> 
> (gdb) bt
> #0  0xb75d8f91 in strcmp () from /lib/libc.so.6
> #1  0x080c5e8e in compare_symbol (a=0x84ed040, b=0x84ed030) at
> #symbols.c:311
> ....
> ....
> ....
> #37 0x080b2581 in main (argc=12, argv=0xbfe97994) at main.c:769
> 
> (gdb) frame 1
> #1  0x080c5e8e in compare_symbol (a=0x84ed040, b=0x84ed030) at
> #symbols.c:311
> 311             ret = strcmp(a->str, b->str);
> 
> (gdb) print a->str
> $1 = (gchar *) 0x0
> 
> (gdb) print b->str
> $2 = (gchar *) 0x0
> 
> 
> As you can see, compare_symbol() calls strcmp(0x0,0x0) but I don't
> know enough about what's happening to know if it's OK just to check
> if ( a->str && b->str ) else return 0, or maybe there is a problem
> with the upstream code that this should never happen anyway.
The upstream code(we are talking about tagmanager?) isn't the problem.
The problem is my code, as usual ;-). Should be double-fixed in SVN
r1767 (double because the cause and effect were fixed).

In case anyone is interested in, the affecting code is in symbols.c
around line 365. If the current file encoding is something else than
UTf-8 than the parsed tag names are converted into UTF-8 by
encodings_convert_to_utf8_from_charset() which is more or less just
calling g_convert() (from GLib) with the file's encoding. But if the
file has no encoding, it actually has the encoding "None" and g_convert
can't encode a file into "None" ;-) so it returns NULL. The first fix
was to skip conversion into UTF-8 when the encoding is None and the
second fix was to skip NULL tag names.

Regards,
Enrico

-- 
Get my GPG key from http://www.uvena.de/pub.key
Powered by Debian GNU/Linux, GnuPG and Sylpheed.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/users/attachments/20070731/d10e48b5/attachment.pgp>


More information about the Users mailing list