#421025 XCreateFontSet fails with fixed 13 as first font pattern in UTF-8 environment

Package:
libx11-6
Source:
libx11
Description:
X11 client-side library
Submitter:
Ben Hutchings
Date:
2013-09-08 21:27:05 UTC
Severity:
normal
#421025#5
Date:
2007-04-25 22:04:24 UTC
From:
To:
--- Please enter the report below this line. ---
Test program:

Debian Release: 4.0
  500 testing         shadbolt
  500 testing         mirror
  100 unstable        mirror
--- Package information. ---
Depends            (Version) | Installed
============================-+-=============
libc6           (>= 2.3.6-6) | 2.3.6.ds1-13
libxau6                      | 1:1.0.1-2
libxdmcp6                    | 1:1.0.1-2
libx11-data                  | 2:1.0.3-7

#421025#10
Date:
2007-04-26 19:21:44 UTC
From:
To:
tags 421025 +unreproducible moreinfo
thank you



Ben Hutchings wrote:
    $ LC_CTYPE=fr_FR ./prout '-*-fixed-*-*-*-*-13-*-*-*-*-*-*-*'
    default:
    $ LC_CTYPE=fr_FR.utf8 ./prout '-*-fixed-*-*-*-*-13-*-*-*-*-*-*-*'
    missing: KSC5601.1987-0
    missing: GB2312.1980-0
    default:
(the other cases get either the first or the second output from above).

Could you try to debug a little bit and see while it fails?

Brice

#421025#17
Date:
2007-04-26 22:06:16 UTC
From:
To:
Was the fr_FR.utf8 locale actually installed on the test system?  I
found that the test passes for UTF-8 locales that aren't actually
installed.

I don't know where to look.  strace shows no system call failures, but
it can dump the X protocol conversation (-e read=3 -e write=3).  Would
that be useful?

Ben.

#421025#22
Date:
2007-04-26 22:19:34 UTC
From:
To:
Ben Hutchings wrote:

Yes (I am french actually):

$ locale -a
C
POSIX
en_US
en_US.iso88591
en_US.iso885915
en_US.utf8
fr_FR
fr_FR.iso88591
fr_FR.iso885915@euro
fr_FR.utf8
fr_FR@euro
français
french

I was rather thinking of locating where this assertion is (I don't see
it in libx11, strace/gdb might help to locate the library or binary
where it comes from). And then try to understand where the error comes
from by either reading the corresponding code, or adding some debug
printf. Not very easy...

Brice

#421025#27
Date:
2007-04-26 22:46:56 UTC
From:
To:
Brice Goglin wrote:
your program, not in fontset.c in a lib :)

Now we have to understand why the code at the URL below returns NULL:
http://git.debian.org/?p=pkg-xorg/lib/libx11.git;a=blob;f=src/FSWrap.c;h=10634ceecae26eab5306507cadda2181019ae2be;hb=HEAD#l167

That would be either XOpenOM returning NULL, or XCreateOC returning
NULL, or list->charset_list && *missing_charset_list == NULL...

Brice

#421025#32
Date:
2007-04-26 23:20:28 UTC
From:
To:
Doesn't depend on the font name.

It's got to be that one.

If list->charset_list != NULL and list->charset_count == 0, the Xmalloc
call in copy_string_list might return NULL (I don't know whether it
supports a size of 0), causing copy_string_list and XCreateFontSet() to
return NULL.  This seems unlikely to be triggered only by the exact font
pattern lists I identified though.

Ben.

#421025#37
Date:
2007-08-10 09:48:07 UTC
From:
To:
Ben Hutchings wrote:

By the way, did you try with libx11-6 2:1.1.3-1 currently in experimental?

Brice

#421025#42
Date:
2007-09-23 05:29:49 UTC
From:
To:
I have tried this now, and the assertion still fails.

I traced through the call with gdb and symbols from the libx11-dbg
package.  Most of the interesting code is in omGeneric.c; XCreateFontSet
indirectly calls create_oc in this file.  This gets some configuration
from files in /usr/share/X11/locale.  The "locale.dir" file specifies
that most UTF-8 locales should get font set configuration from
"en_US.UTF-8/XLC_LOCALE".  That specifies that it should look for fonts
covering the following character sets:

0. ISO8859-1
1. ISO8859-1 (again)
2. JISX0208.1983-0
3. KSC5601.1987-0
4. GB2312.1980-0
5. JISX0201.1976-0
6. ISO10646-1

parse_fontname somehow comes up with the following font names for these,
respectively:

0. -misc-fixed-bold-r-normal--13-100-100-100-c-70-iso8859-1
1. -misc-fixed-bold-r-normal--13-100-100-100-c-70-iso8859-1
2. -jis-fixed-medium-r-normal--13-94-100-100-c-0-jisx0208.1983-0
3. (nothing)
4. (nothing)
5. -misc-fixed-medium-r-normal--13-94-100-100-c-0-jisx0201.1976-0
6. -misc-fixed-bold-r-normal--13-120-75-75-c-70-iso10646-1

Then load_font_info calls XListFontsWithInfo for each of these names.
This fails for
"-jis-fixed-medium-r-normal--13-94-100-100-c-0-jisx0208.1983-0", and the
error propagates up to the caller of XCreateFontSet.  It would also fail
for "-misc-fixed-medium-r-normal--13-94-100-100-c-0-jisx0201.1976-0".

parse_fontname is calling parse_omit_name, which combines the font
name(s) originally passed to XCreateFontSet with a given character set
and then calls get_font_name, which calls XListFonts.  And XListFonts
for "-*-fixed-*-*-*-*-13-*-*-*-*-*-JISX0208.1983-0" returns
"-jis-fixed-medium-r-normal--13-94-100-100-c-0-jisx0208.1983-0".

XListFonts does little other than making a request to the server.  So I
guess this is really a server bug.

Here's a new test program:

#include <assert.h>
#include <stdio.h>

#include <X11/Xlib.h>

int main(int argc, char ** argv)
{
    Display * display;
    char **name_list, **name_list_2;
    int count, count_2, i;
    XFontStruct *info;

    assert(argc >= 2);
    display = XOpenDisplay(0);
    assert(display);
    name_list = XListFonts(display, argv[1], 10, &count);
    assert(name_list);

    for (i = 0; i != count; ++i)
    {
	name_list_2 = XListFontsWithInfo(display, name_list[i], 1, &count_2,
					 &info);
	if (name_list_2)
	{
	    printf("%s exists\n", name_list[i]);
	    XFreeFontInfo(name_list_2, info, count_2);
	}
	else
	{
	    printf("%s doesn't exist!\n", name_list[i]);
	}
    }

    XFreeFontNames(name_list);

    return 0;
}

Run this with the argument
"-*-fixed-*-*-*-*-*-*-*-*-*-*-JISX0208.1983-0" and you should see the
bug (or not).

Ben.

#421025#47
Date:
2007-09-23 14:37:10 UTC
From:
To:
On Sun, 2007-09-23 at 06:29 +0100, Ben Hutchings wrote:
<snip>

I suspect you won't see it.

With my normal X server I get:

$ ./listfonts -*-fixed-*-*-*-*-13-*-*-*-*-*-JISX0208.1983-0
-jis-fixed-medium-r-normal--13-94-100-100-c-0-jisx0208.1983-0 doesn't exist!
-misc-fixed-medium-r-normal--13-94-100-100-c-0-jisx0208.1983-0 doesn't exist!

With an Xvfb server in a clean etch chroot I get:

$ DISPLAY=:1 ,/listfonts -*-fixed-*-*-*-*-13-*-*-*-*-*-JISX0208.1983-0
-jis-fixed-medium-r-normal--13-94-100-100-c-0-jisx0208.1983-0 exists
-misc-fixed-medium-r-normal--13-94-100-100-c-0-jisx0208.1983-0 exists

However:

$ xlsfonts | grep jisx0208
-jis-fixed-medium-r-normal--0-0-75-75-c-0-jisx0208.1983-0
-jis-fixed-medium-r-normal--16-110-100-100-c-160-jisx0208.1983-0
-jis-fixed-medium-r-normal--16-150-75-75-c-160-jisx0208.1983-0
-jis-fixed-medium-r-normal--24-170-100-100-c-240-jisx0208.1983-0
-jis-fixed-medium-r-normal--24-230-75-75-c-240-jisx0208.1983-0
-misc-fixed-medium-r-normal--0-0-75-75-c-0-jisx0208.1983-0
-misc-fixed-medium-r-normal--14-130-75-75-c-140-jisx0208.1983-0
$ diff <(xlsfonts | grep jisx0208) <(DISPLAY=:1 xlsfonts | grep jisx0208) && echo same
same

And:

$ ./listfonts -jis-fixed-medium-r-normal--0-0-75-75-c-0-jisx0208.1983-0
-jis-fixed-medium-r-normal--0-0-75-75-c-0-jisx0208.1983-0 doesn't exist!
$ DISPLAY=:1 ./listfonts -jis-fixed-medium-r-normal--0-0-75-75-c-0-jisx0208.1983-0
-jis-fixed-medium-r-normal--0-0-75-75-c-0-jisx0208.1983-0 exists

It seems like the servers are offering (in XListFonts) to make 13-pixel
fixed for JISX0208 by scaling the 14-pixel or 16-pixel bitmap (ugh!),
but my normal X server then disavows that in XListFontsWithInfo.  Where
do we go from here?

Ben.

#421025#52
Date:
2009-06-02 20:42:56 UTC
From:
To:
Hello,
I encounter this bug on the one of my lenny systems.
I can't track this down, but I seem to find a working solution.

After 'xset +fp /usr/share/fonts/X11/misc/:unscaled' command the xserver
starts to return the same list of fonts for XListFonts and XListFontsWithInfo calls.
Moreover, deleting this item from font path by 'xset -fp ...' or even 'xset fp default'
leaves the expected behavior.

#421025#57
Date:
2013-09-08 21:23:43 UTC
From:
To:
Hi,

Ben Hutchings wrote (23 Sep 2007 14:37:10 GMT) :

In case it helps, on my up-to-date sid system:

$ listfonts "-*-fixed-*-*-*-*-*-*-*-*-*-*-JISX0208.1983-0"
-jis-fixed-medium-r-normal--16-110-100-100-c-160-jisx0208.1983-0 exists
-jis-fixed-medium-r-normal--16-150-75-75-c-160-jisx0208.1983-0 exists
-jis-fixed-medium-r-normal--24-170-100-100-c-240-jisx0208.1983-0 exists
-jis-fixed-medium-r-normal--24-230-75-75-c-240-jisx0208.1983-0 exists
-misc-fixed-medium-r-normal--14-130-75-75-c-140-jisx0208.1983-0 exists
-jis-fixed-medium-r-normal--17-120-100-100-c-0-jisx0208.1983-0 exists
-jis-fixed-medium-r-normal--0-0-75-75-c-0-jisx0208.1983-0 exists
-misc-fixed-medium-r-normal--17-120-100-100-c-0-jisx0208.1983-0 exists
-misc-fixed-medium-r-normal--0-0-75-75-c-0-jisx0208.1983-0 exists

Cheers,
--
  intrigeri
  | GnuPG key @ https://gaffer.ptitcanardnoir.org/intrigeri/intrigeri.asc
  | OTR fingerprint @ https://gaffer.ptitcanardnoir.org/intrigeri/otr.asc