From: malowany@cs.concordia.ca (Stephen Malowany)
Subject: fs hates me!!! (or I found a bug)
Keywords: font server, fs, bug
Organization: Computer Science, Concordia University, Montreal, Quebec
Date: Fri, 13 Nov 1992 00:23:36 GMT

I'm trying to use fs to serve fonts to bunch of Sun3/50 Xkernel Xterminals
with limited success. First some background:

      fs: X11R5 pl.17, SPARC, SunOS 4.1.1, bundled cc.
XsunMono: X11R5 pl.17, Sun3,  SunOS 4.1.1, gcc2.2.2

fs runs on SS2's serving about 15-20 X terminals each. First I tried the
"cloning" method: port = 7000, clone-self = on, client-limit = 10.
Connecting to fs using "XsunMono -fp <fonthost>:7000" on the sun3's was
not very robust. Often, I'd have to reboot the X terminals 2 or 3+ times
to get Xsun up and running (dies with "could not set default font: fixed").
After a few days of random X terminal crashes, there ends up being around
6 cloned instances of fs running, whereas I only want/need 2 or 3. Every
now and then the parent fs process would die, hence the next X terminal
to reboot couldn't get a connection until all existing fs processes were
killed and a new parent started. On two occasions I cought the parent fs
stuck in a loop burning up all the CPU. "trace -p <fspid>" showed it
looping over and over again through

read (8, 0x94d90, 4096) = -1 EAGAIN (No more processes)
gettimeofday (0xf7fffd80, 0) = 0
select (128, 0x36248, 0, 0, 0xf7fffe00) = 6
gettimeofday (0xf7fffd80, 0) = 0

(there were plenty of processes left, BTW). The second time it was
stuck looping through

select (128, 0x36248, 0, 0, 0xf7fffe00) = 1
gettimeofday (0xf7fffd80, 0) = 0
gettimeofday (0xf7fffd80, 0) = 0

So I figure I'll try something different. This time I start 3 fs's; one
each on ports 7000, 7001, 7002, with "clone-self = off". The config file
for port 7000 has "alternate-servers = cyclops:7001,cyclops:7002". This
works for a half-hour or so (load dependant) until suddenly no amount
of rebooting the 3/50's can get a connection. Back to trace -p again.
After a little digging, I think I have identified the bug.

A healthy fs:7000 accepts up to the specified 10 connections, at which
time it will pass off the connection attempt to the alternate servers
like so
----------------------------------------
gettimeofday (0xf7fffcc0, 0) = 0
select (128, 0x36248, 0, 0, 0xf7fffd40) = 1
gettimeofday (0xf7fffc48, 0) = 0
accept (3, 0, 0) = 14
getpeername (14, 0xf7fffcb4, 0xf7fffcc4) = 0
setsockopt (14, 6, 1, 0xf7fffcb0, 4) = 0
fcntl (14, 04, 0x4000) = 0
select (15, 0xf7fffc30, 0, 0, 0xf7fffc40) = 1
read (14, "B", 1) = 1
write (14, "".., 12) = 12
write (14, "".., 2) = 2
write (14, "cyclops:7001", 12) = 12
write (14, "".., 2) = 2
write (14, "".., 2) = 2
write (14, "cyclops:7002", 12) = 12
write (14, "".., 2) = 2
close (14) = 0
gettimeofday (0xf7fffcc0, 0) = 0
----------------------------------------
Note the write of "cyclops:7001" and "cyclops:7002". But, it's
not long before the fs gets "sick" and starts responding like so
----------------------------------------
gettimeofday (0xf7fffcc0, 0) = 0
select (128, 0x36248, 0, 0, 0xf7fffd40) = 1
gettimeofday (0xf7fffc48, 0) = 0
accept (3, 0, 0) = 14
getpeername (14, 0xf7fffcb4, 0xf7fffcc4) = 0
setsockopt (14, 6, 1, 0xf7fffcb0, 4) = 0
fcntl (14, 04, 0x4000) = 0
select (15, 0xf7fffc30, 0, 0, 0xf7fffc40) = 1
read (14, "B", 1) = 1
write (14, "".., 12) = 12
write (14, "".., 2) = 2
write (14, "????\0\0\0\2", 8) = -1 EFAULT (Bad address)
write (14, "".., 2) = 2
write (14, "".., 2) = 2
write (14, "", 0) = 0
write (14, "".., 2) = 2
close (14) = 0
gettimeofday (0xf7fffcc0, 0) = 0
----------------------------------------
Note the "????\0\0\0\2" where it should be writing "cyclops:7001",
and "" where it should be writing "cyclops:7002". So how 'bout it,
is this a legit bug? Anyone know the fs code well enough to know
how and where to fix this?

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Steve Malowany                                               Systems Analyst
Centre for Pattern Recogn. & Machine Intell.  malowany@cenparmi.concordia.ca
Department of Computer Science                      malowany@cs.concordia.ca
Concordia University                                Montreal, Quebec, Canada
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Newsgroups: comp.windows.x