PATCH: for Serious v3 shared library bug

Phil Edwards pedwards@disaster.jaj.com
Tue Jan 2 17:30:00 GMT 2001


[gcc-patches snipped since I'm not addressing the patch itself]

On this issue of file descriptors:


On Tue, Jan 02, 2001 at 06:45:04PM -0600, Loren James Rittle wrote:
> In article < 200101022253.f02MrkO36439@latour.rsch.comm.mot.com >, I wrote:
> 
> I accidentally tested libstdc++-v3 with only those tests that had been
> failing not the full suite (as I know to do).  A full bootstrap and
> test cycle has just revealed that this test now fails (since stdX and
> cX are using different underlying file descriptors with the first
> version of the patch):
> 
> 27_io/ios_base_members_static.cc
> 
> If the special case logic that I mentioned is implemented, then this
> failure should be resolved.  I will post that patch after I fully test
> it but I wanted to alert everyone of my mistake ASAP.

This things feels like a schroedinbug!

A few weeks ago I started investigating that exact test; see my message on
(I think) the 22nd about sync_with_stdio().  That non-standard __sys_open is
proving to be both our friend and enemy in the implemented-using-stdio case.
And tracing things that happen before main isn't working for me in gdb,
so there's too much guesswork involved.


I had changed sync_with_stdio() to behave more like ios_base::Init::Init():
save a pointer to the old filebuf, construct a new one using the non-std
fd-passing ctor, destroy the old filebuf.  But the descriptors kept
getting closed because (under solaris) the stdio implementation is used.
Variations on this theme don't help.

Now I have a new Linux system, and not a single C++ program will run.  Ha.
So I haven't gotten back to the Solaris system yet.

This brings two questions to my mind.  Forgive me if I'm being stupid;
I haven't gotten enough sleep.

1)  How does ios_base::Init::Init() get away with calling __old->~streambuf()
to dispose of buffers, where doing the same thing during sync_with_stdio()
closes the descriptors?

2)  If we treat file descriptors 0/1/2 specially -- as we are in
ios_base::Init::Init() and sync_with_stdio() -- then are we /really/
using a separate buffer after de-synch'ing from stdio?



Phil

-- 
pedwards at disaster dot jaj dot com  |  pme at sources dot redhat dot com
devphil at several other less interesting addresses in various dot domains
The gods do not protect fools.  Fools are protected by more capable fools.


More information about the Libstdc++ mailing list