Bug 464 - [Xorg/XPRINT] Xprt crashes when using PMF fonts
Summary: [Xorg/XPRINT] Xprt crashes when using PMF fonts
Status: RESOLVED FIXED
Alias: None
Product: xprint
Classification: Unclassified
Component: Server: Font engine: PMF (show other bugs)
Version: unspecified
Hardware: All All
: high blocker
Assignee: Alan Coopersmith
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 461
  Show dependency treegraph
 
Reported: 2004-04-13 11:07 UTC by Roland Mainz
Modified: 2004-04-19 06:43 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Workaround (patch for 2004-04-15-trunk) (6.57 KB, patch)
2004-04-14 16:54 UTC, Roland Mainz
no flags Details | Splinter Review
Patch for 2004-04-20-trunk (601 bytes, patch)
2004-04-20 16:41 UTC, Roland Mainz
no flags Details | Splinter Review

Description Roland Mainz 2004-04-13 11:07:08 UTC
After landing the Xprint tree on the Xorg/XPRINT branch it seems that PMF fonts
are completely broken and their usage ends in a crash.

Steps to reproduce (/tmp/thaitest/xprint/install/usr/X11R6/lib/X11/xserver are
the config files from an unpacked Xprint binary tarball):
% export CVSROOT=:ext:myaccountname@cvs.freedesktop.org:/cvs/xorg
% export CVS_RSH=ssh
% ls -la
% cvs -z6 checkout -r XPRINT -P xc
% cd xc/
% time nice make World 2>&1 | tee -a buildlog.log
% cd programs/Xserver/
% ls -l Xprt
% (ulimit -c unlimited ; export
XPCONFIGDIR=/tmp/thaitest/xprint/install/usr/X11R6/lib/X11/xserver ; ./Xprt -ac
-audit 4 -core 
-fp $(find /usr/X11R6/lib/X11/fonts -type d | grep -v "/.*dpi" | tr "\n" ",")
:50)
# Print http://www.mozilla.org/start/ using Mozilla, printer name
"xp_ps_spooldir_tmp_Xprintjobs"...
% file core
% gdb ./Xprt core

Stack trace looks like this:
-- snip --
% gdb ./Xprt core
GNU gdb 5.3
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i586-suse-linux"...
Core was generated by `./Xprt -ac -audit 4 -core -fp
/usr/X11R6/lib/X11/fonts,/usr/X11R6/lib/X11/fonts'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/lib/libfreetype.so.6...done.
Loaded symbols for /usr/lib/libfreetype.so.6
Reading symbols from /lib/libz.so.1...done.
Loaded symbols for /lib/libz.so.1
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
#0  0x0806416c in LoadGlyphs ()
(gdb) where
#0  0x0806416c in LoadGlyphs ()
#1  0x08063320 in doPolyText ()
#2  0x0806373d in PolyText ()
#3  0x0806dd1c in ProcPolyText ()
#4  0x08069d90 in Dispatch ()
#5  0x08057998 in main ()
#6  0x400c48ae in __libc_start_main () from /lib/libc.so.6
-- snip --
Renaming the fonts.dir file in
/tmp/thaitest/xprint/install/usr/X11R6/lib/X11/xserver/C/print/models/PSspooldirt/fonts/fonts.dir
to any other name (e.g. disabling PMF fonts) works around the crash.

Something in PMF font handling was changed between X11R6.6 and X11R6.7... but I
have no clue what was broken... ;-(

Alan:
Can you help, please ?
Comment 1 Roland Mainz 2004-04-13 23:51:25 UTC
Mhhh, before one crash I got:
-- snip --
Error: Couldn't allocate bitmaps (0)
-- snip --
Comment 2 Roland Mainz 2004-04-14 14:24:16 UTC
Full stack trace of one if the crashes:
-- snip --
AUDIT: Wed Apr 14 23:16:21 2004: 17475 Xprt: client 1 disconnected
Could not init font path element /usr/X11R6/lib/X11/fonts/encodings, removing
from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/kwintv, removing from
list!
Could not init font path element /usr/X11R6/lib/X11/fonts/local, removing from
list!
AUDIT: Wed Apr 14 23:16:22 2004: 17475 Xprt: client 1 connected from local host
Error: Couldn't allocate bitmaps (0)
Xprint server pid=17475 done, exitcode=0.

gismobile@puzzle:/tmp/yyy/xprint> file core 
core: ELF 32-bit LSB core file of 'Xprt' (signal 11), Intel 80386, version 1
(SYSV), from 'Xprt'
gismobile@puzzle:/tmp/yyy/xprint> gdb ./install/usr/X11R6/bin/Xprt core
GNU gdb 5.3
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i586-suse-linux"...
Core was generated by `/tmp/yyy/xprint/install/usr/X11R6/bin/Xprt -ac -pn
-nolisten tcp -audit 4 -fp /'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/lib/libfreetype.so.6...done.
Loaded symbols for /usr/lib/libfreetype.so.6
Reading symbols from /lib/libz.so.1...done.
Loaded symbols for /lib/libz.so.1
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
#0  0x08068b6f in FreeFPE (fpe=0x0) at dixfonts.c:233
233         fpe->refcount--;
(gdb) where
#0  0x08068b6f in FreeFPE (fpe=0x0) at dixfonts.c:233
#1  0x08068fbc in doOpenFont (client=0x8699268, c=0x868b4a8) at dixfonts.c:377
#2  0x08069226 in OpenFont (client=0x8699268, fid=2097168, flags=0, lenfname=61, 
    pfontname=0x8710dec
"-adobe-avantgarde-demi-r-normal--50-*-2540-2540-p-*-iso8859-1\001\003") at
dixfonts.c:471
#3  0x08074fc8 in ProcOpenFont (client=0x8699268) at dispatch.c:1297
#4  0x080733e1 in Dispatch () at dispatch.c:454
#5  0x0805a6f1 in main (argc=11, argv=0xbffff224, envp=0xbffff254) at main.c:440
#6  0x400c48ae in __libc_start_main () from /lib/libc.so.6
(gdb) quit
-- snip --
Comment 3 Roland Mainz 2004-04-14 16:54:39 UTC
Created attachment 201 [details] [review]
Workaround (patch for 2004-04-15-trunk)

The patch seems to work around the problem...
... but I have no clue why.

Alan:
Any ideas ?
Comment 4 Roland Mainz 2004-04-20 15:02:30 UTC
Somehow I feel the NUM_SEGMENTS() call is completely on drugs here:
In xc/lib/font/include/bitmap.h |NUM_SEGMENTS()| is defined as
-- snip --
/* number of encoding entries in one segment */
#define BITMAP_FONT_SEGMENT_SIZE 128
[snip]
#define NUM_SEGMENTS(n) \
  (((n)+BITMAP_FONT_SEGMENT_SIZE-1)/BITMAP_FONT_SEGMENT_SIZE)
-- snip --

Adding a simple fprintf(stderr, ...) to print the size of the macro input and
output like this:
-- snip --
Index: xc/lib/font/bitmap/pcfread.c
===================================================================
RCS file: /cvs/xorg/xc/lib/font/bitmap/pcfread.c,v
retrieving revision 1.1.4.2.6.1
diff -u -r1.1.4.2.6.1 pcfread.c
--- a/xc/lib/font/bitmap/pcfread.c      4 Mar 2004 17:47:10 -0000      
1.1.4.2.6.1
+++ b/xc/lib/font/bitmap/pcfread.c      20 Apr 2004 04:59:22 -0000
@@ -896,8 +896,18 @@
     nencoding = (pFont->info.lastCol - pFont->info.firstCol + 1) *
        (pFont->info.lastRow - pFont->info.firstRow + 1);
 
+#if 1
+    /* Workaround for
http://xprint.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=464
+     * ("[Xorg/XPRINT] Xprt crashes when using PMF fonts") */
+    encoding = (CharInfoPtr **) xcalloc(MAX(NUM_SEGMENTS(nencoding), 512+1),
+                                       sizeof(CharInfoPtr*));
+
+fprintf(stderr, "pmf: 1=%ld, 2=%ld\n", (long)NUM_SEGMENTS(nencoding),
(long)nencoding);
+#else
     encoding = (CharInfoPtr **) xcalloc(NUM_SEGMENTS(nencoding),
                                        sizeof(CharInfoPtr*));
+#endif
+
     if (!encoding) {
       pcfError("pmfReadFont(): Couldn't allocate encoding (%d*%d)\n",
nencoding, sizeof(CharInfoPtr));
        goto Bail;
-- snip --
results in the following output:
-- snip --
AUDIT: Tue Apr 20 05:52:29 2004: 16811 Xprt: client 1 connected from local host
pmf: 1=2, 2=224
pmf: 1=2, 2=224
pmf: 1=2, 2=224
pmf: 1=2, 2=224
pmf: 1=2, 2=224
pmf: 1=2, 2=224
pmf: 1=2, 2=224
pmf: 1=2, 2=224
pmf: 1=2, 2=224
pmf: 1=2, 2=224
pmf: 1=2, 2=224
pmf: 1=2, 2=224
AUDIT: Tue Apr 20 05:52:31 2004: 16811 Xprt: client 1 disconnected
-- snip --

... no wonder this goes BOOOM! ... ;-(
Comment 5 Roland Mainz 2004-04-20 16:41:17 UTC
Created attachment 217 [details] [review]
Patch for 2004-04-20-trunk

The previous analysis was slighly wrong, it seems to be sufficient to remove
the |encoding[i] = 0;| statement as it was done by keithp for the PCF copy of
that code long ago for XF86...
Comment 6 Roland Mainz 2004-04-20 16:43:25 UTC
Patch checked-in...

Checking in lib/font/bitmap/pcfread.c;
/cvs/xorg/xc/lib/font/bitmap/pcfread.c,v  <--  pcfread.c
new revision: 1.1.4.2.6.1.6.1; previous revision: 1.1.4.2.6.1
done
Mailing the commit message to xorg-commit@pdx.freedesktop.org...
Mailing xorg-commit-diffs@freedesktop.org...
Generating notification message...
Generating notification message... done.

... marking bug as FIXED.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.