Re: glib's g_logv 1024 byte maximum character array
- From: Magnus Bergman <magnusbe algonet se>
- To: gtk-devel-list gnome org
- Subject: Re: glib's g_logv 1024 byte maximum character array
- Date: Tue, 22 Jul 2003 15:40:15 +0000
On Tue, 22 Jul 2003 09:31:03 +0100
martyn 2 russell bt com wrote:
> I had a bug reported against my application which basically meant that
> information being written to a iochannel was not valid UTF8.
>
> I narrowed it down, checking the text at every stage and the buffer was
> valid UTF8 up until the point I call g_message("%s", buffer) with it.
>
> The 'buffer' argument is more than 1024 bytes in this particular case, and
> when I check the message which has passed through the g_log() functions I
> notice that it is no more than 1024 bytes.
>
> I check the Glib code to find that it has a character array with a maximum
> size of 1025 bytes and this array is used in the function _g_vsnprintf(), on
> line 437 here:
> http://cvs.gnome.org/bonsai/cvsblame.cgi?file=glib%2Fglib/gmessages.c&rev=&r
> oot=/cvs/gnome
>
> The problem I face is that I am passing an argument which is more than 1025
> bytes and is filled with multibyte characters. I suspect the reason I get
> an "invalid utf8" error is because at the 1024th byte, it is half way
> through a (in this case Russian) multibyte character, causing incomplete
> UTF8 characters and hence, invalid UTF8.
>
> Should I be limiting all my arguments to 1024 bytes? or should this be an
> improvement in Glib?
I'm quite sure this limit is inherited from the syslog protocol (which will be used to transfer the log messages in many cases). The specification of the syslog protocol says that both the header and the message together must be at most 1024 bytes (see RFC 3164 section 4.1).
My recomendation is to keep log messages very brief (about one line of text) and maybe log additional information separately with debug severity.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]