Subject: Shared libs + stdio
To: None <current-users@sun-lamp.cs.berkeley.edu>
From: Frank van der Linden <vdlinden@fwi.uva.nl>
List: current-users
Date: 11/07/1993 16:31:58
(I have only just subscribed to this list, so it could be that this has been
discussed before, sorry in that case).
While playing around with the shared libs, I seem to have stumbled on a bug.
I have made all shared libraries, by recompiling gcc, gas, ld, and compiling
in /usr/src/lib, etc. Then Xfree 2.0 came out, so I started compiling X
with shared libs (after changing some of the Imake .rules and .tmpl files).
Somewhere in libX it went wrong. It turned out, that some X util program
produced an incorrect .h file, because its stdio buffers weren't flushed.
It seems, that open filestreams are not flushed right at exit time, when
using shared libraries. To be more precise: _cleanup() is called allright,
but when _fwalk() (all from the stdio lib) is called, to call __sflush(),
the latter is passed a bogus file structure pointer. An explicit fflush(stdout)
in exit(), or wherever, works. Statically linked programs also always work fine.
I'm not sure what is going on here. The file pointers for stdin, stdout and
stderr are stored statically, while the rest is appended dynamically. Maybe
there's something here that confuses the runtime linker. Or is it just
something that confuses me.
Frank
------------------------------------------------------------------------------