[MAJOR BUG] g++ 2.95.x generates invalid code for KDE 3.3.0

Thiago Macieira thiago.macieira at kdemail.net
Sun Sep 19 14:24:59 BST 2004


Leo Savernik wrote:
>No, it's the genuine gcc-2.95. I discovered the bug, and Thiago confirmed
> it. So it *is* serious.

After some more testing, the bug happens in the following cases:

- the virtual base is not the first ancestor
- a constructor for one of the classes inheriting the virtual base calls one 
function which in turn calls an overridden virtual function

I.e., during KBufferedSocket creation, the KStreamSocket constructor calls 
KSocketBase::setBlocking, which in turn calls the virtual setSocketOptions, 
which is overriden in KClientSocketBase.

At that moment, the object is still a KStreamSocket, with the virtual tables 
being provided by KStreamSocket (both for the main object and the virtual 
base). When one overriden virtual function is called from a non-direct 
base, it goes through a thunk stub to adjust the "this" pointer. Problem 
is: that thunk is also provided by KStreamSocket -- which is wrong, because 
the real object is not a KStreamSocket, but a KBufferedSocket

With g++ 3.3/3.4, the virtual tables are provided by the most-derived 
constructor (i.e., KBufferedSocket) -- the so-called "construction virtual 
table". This solves the problem.

So, I can come up with a quick-fix: remove the "setBlocking(false)" from the 
constructors. This should, *AFAICS*, workaround the problem. But also note 
that this introduces a behaviour change because KStreamSocket's will be 
blocking by default now. KBufferedSocket may in some occasions report that 
it is blocking when in fact it is not.

Patch is attached. Leo: please test it.

And I SERIOUSLY recommend that for KDE 4, gcc 2.95 is no longer supported.
-- 
  Thiago Macieira  -  Registered Linux user #65028
   thiago (AT) macieira (DOT) info
    ICQ UIN: 1967141   PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kstreamsocket-gcc2.95.patch
Type: text/x-diff
Size: 1199 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20040919/de1ed1a2/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20040919/de1ed1a2/attachment.sig>


More information about the kde-core-devel mailing list