|
From: Allin C. <cot...@wf...> - 2015-03-06 16:21:30
|
On Tue, 3 Mar 2015, sfeam wrote:
> On Wednesday, 04 March 2015 09:54:08 AM Tatsuro MATSUOKA wrote:
>> [...]
>> I copy the back trace.
>
>> For wxt terminal,
>> (gdb) bt
>> #0 0x6862318f in g_utf8_validate (str=0x2a97fc8 "-1", max_len=-1,
>> end=0xffffffff) at ../../glib-2.42.1/glib/gutf8.c:1634
>> #1 0x00529d21 in gp_cairo_convert (plot=0x2a0e0f0, string=0x2a97fc8 "-1")
>> at ../../src/wxterminal/gp_cairo.c:737
>
> [snip]
>
> I think this indicates a bug in glib.
> Gnuplot is prepared for an error return from the call to g_utf8_validate,
> but apparently glib faults instead of cleanly returning an error.
> The gnuplot code is:
> if (g_utf8_validate(string, -1, NULL)) {
> string_utf8 = g_strdup(string);
> } else {
> charset = gp_cairo_get_encoding(plot);
> string_utf8 = g_convert(string, -1, "UTF-8", charset, &bytes_read, NULL, &error);
> }
I think there must be more going on here than meets the eye.
g_utf8_validate is a very basic glib function, I use it "all the time"
in the same form as here (with -1 and NULL for the second and third
arguments) and I've never seen it segfault on any platform or in any
glib version up to 2.24.2.
Probably unrelated, but in looking at the gp_cairo.c code I noticed
one definite bug: in an error-response path in gp_cairo_convert on
line 750 the empty string "" is returned. Since the callers free the
return from gp_cairo_convert this will surely cause a segfault if it's
ever triggered. The return value here should either be NULL (if the
callers are ready to handle that), or g_strdup("").
Allin Cottrell
|