Subject: xsrc/25071: 2.0: libXft cores when fonts.cache-1 timestamp old
To: None <gnats-bugs@gnats.netbsd.org>
From: Hubert Feyrer <feyrer@smaug.fh-regensburg.de>
List: netbsd-bugs
Date: 04/06/2004 14:37:15
>Number:         25071
>Category:       xsrc
>Synopsis:       2.0: libXft cores when fonts.cache-1 timestamp old
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    xsrc-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 06 12:38:01 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Hubert Feyrer
>Release:        NetBSD 2.0_BETA1
>Organization:
Hubert Feyrer <hubertf@NetBSD.org>
>Environment:
	NetBSD miyu 2.0_BETA NetBSD 2.0_BETA (MIYU) #45: Wed Mar 31 13:28:17 MEST 2004  feyrer@miyu:/home/cvs/src-2.0/sys/arch/i386/compile/MIYU i386

Architecture: i386
Machine: i386
>Description:
On new installed 2.0_BETA system, "xclock -digital" dumps core
(Xvfb is only used here because I'm not on the system's console):

	# Xvfb :1
	# xclock -digital -display :1
	Warning: Cannot convert string "" to type XftFont
	[2]   Segmentation fault (core dumped) xclock -digital -display :1
	# Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!
	#
	# gdb /usr/X11R6/bin/xclock xclock.core
	...
	Core was generated by `xclock'.
	Program terminated with signal 11, Segmentation fault.
	...
	(gdb) 
	(gdb) bt
	#0  0x480689ac in XftCharIndex () from /usr/X11R6/lib/libXft.so.2
	#1  0x48070f14 in XftTextExtents8 () from /usr/X11R6/lib/libXft.so.2
	#2  0x0804a57f in Initialize ()
	#3  0x4819b3a9 in XtInitializeWidgetClass () from /usr/X11R6/lib/libXt.so.6
	#4  0x4819b8bb in XtInitializeWidgetClass () from /usr/X11R6/lib/libXt.so.6
	#5  0x4819bcbc in _XtCreateWidget () from /usr/X11R6/lib/libXt.so.6
	#6  0x4819bf33 in XtCreateManagedWidget () from /usr/X11R6/lib/libXt.so.6
	#7  0x08049d7e in main ()
	#8  0x0804988a in ___start ()
	(gdb) 


Looking a bit further, this whole situation is aparently
depending on the timestamp of the fonts.cache-1 file:

	# touch  /usr/X11R6/lib/X11/fonts/100dpi/fonts.cache-1
	# xclock -digital -display :1
	*works*
	^C
	#
	# touch -r/netbsd /usr/X11R6/lib/X11/fonts/100dpi/fonts.cache-1
	# xclock -digital -display :1
	Warning: Cannot convert string "" to type XftFont
	[2]   Segmentation fault (core dumped) xclock -digital -display :1
	# Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!
	#
	# ls -la /netbsd
	-rwxr-xr-x  1 root  wheel  1674812 Apr  3 16:17 /netbsd
	# date
	Tue Apr  6 12:22:30 UTC 2004

=> playing with timestamp of the config.cache-1 file, this works or
	works not.


More investigation,
Setting to oldest file's timestamp in dir:
	# cd /usr/X11R6/lib/X11/fonts/100dpi/
	# 
	# ls -latr | head -2
	total 26900
	-r--r--r--   1 root  wheel    3154 Feb 28  2003 fonts.alias
	# touch -r fonts.alias fonts.cache-1
	# xclock -digital -display :1
	Warning: Cannot convert string "" to type XftFont
	[2]   Segmentation fault (core dumped) xclock -digital -display :1
	# Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!

Setting to latest file's timestamp in dir:
	# ls -latr | tail -10
	-r--r--r--   1 root  wheel    5122 Apr  3 15:07 UTRG__12-ISO8859-15.pcf.gz
	-r--r--r--   1 root  wheel    4655 Apr  3 15:07 UTRG__10-ISO8859-15.pcf.gz
	-r--r--r--   1 root  wheel    8484 Apr  3 15:07 UTI___24-ISO8859-15.pcf.gz
	-r--r--r--   1 root  wheel    1899 Apr  5 18:20 encodings.dir
	-r--r--r--   1 root  wheel       2 Apr  5 18:20 fonts.scale
	-r--r--r--   1 root  wheel  169851 Apr  5 18:21 fonts.dir
	-r--r--r--   1 root  wheel  193184 Apr  6 11:58 fonts.cache-1.orig
	-rw-r--r--   1 root  wheel   39087 Apr  6 11:59 fonts.cache-1.diff
	drwxr-xr-x   2 root  wheel   66048 Apr  6 12:02 .
	drwxr-xr-x  13 root  wheel     512 Apr  6 12:02 ..
	# touch -r fonts.dir fonts.cache-1
	# xclock -digital -display :1
	Warning: Cannot convert string "" to type XftFont
	[2]   Segmentation fault (core dumped) xclock -digital -display :1
	# Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!

Setting past latest file:
	# touch -r . fonts.cache
	# xclock -digital -display :1
	^C

	
>How-To-Repeat:
	do a "build.sh -U release", and unpack somewhere
	chroot somewhere

	Xvfb :1
	xclock -digital -display :1

	see it dump core
	see other steps above

>Fix:
	 * Stopgag:
		somehow touch all fonts.config-1 files or run fc-cache
		after installing. Timestamp in the xfont.tgz set is probably
		irrelevant, because the directory's timestamp is relevant,
		and that probably has no timestamp in that file.
	* Proper:
		Fix libXft to deal better with fonts.cache-1 timestamp.
>Release-Note:
>Audit-Trail:
>Unformatted:
 	Running NetBSD 2.0_BETA1/i386 from netbsd-2-0 branch with
 	XFree86 4.4.0 from xsrc-2-0 branch.