[gnutls-dev] Building GnuTLS 1.6.1 under Mac OS X (fwd)

Eduardo Villanueva Che edu at eduardovillanueva.es
Tue Feb 13 03:23:09 CET 2007


> From: Rupert Kittinger-Sereinig <rks <at> mur.at>
> Subject: Re: Building GnuTLS 1.6.1 under Mac OS X (fwd)
> Newsgroups: gmane.comp.encryption.gpg.gnutls.devel
> Date: 2007-02-01 17:55:51 GMT (1 week, 4 days, 3 hours and 17 minutes
> ago)
> 
> >> I looked up the mail that reported the error, and it seems that the 
> >> compiler fails to create an instance of the set_ptr() member function
> >> in the object file. In this case, I would try to uninline set_ptr(). 
> >> This can hardly be a performance problem and should fix the linker error :-)
> > 
> > I'd really appreciate your help here.  What would your recommendation
> > be, more specifically?  The old code is the one which is used when the
> > newly added #if's are not chosen.  I've seen other bug reports too,
> > such as this failure:
> > 
> >>> verify-elf: ERROR: ./usr/lib/libgnutlsxx.so.13.2.2: undefined symbol: 
> >>> _ZN6gnutls11credentials7set_ptrEPv
> > 
> > But that may actually be the same, I don't know...
> > 
> > /Simon
> 
> Hi Simon,

Hi all, 

I have the same problem with Linux, but the bug is platform independent, it's a C++ issue.

> to make sense of the above error message, you need to feed it through 
> c++filt, so we get
> 
> /usr/lib/libgnutlsxx.so.13.2.2: undefined symbol: 
> gnutls::credentials::set_ptr(void*)
> 
> So, gnutls::credentials::set_ptr(void*) is missing from the library.
>
> The reason is almost certainly that the functions was declared inline. 

No, it's missing because it was declared as pure virtual. Apparently
there are no problem with this, because it was defined in each derived
class. That's OK, but it has one limitation:

A virtual function MUST NOT be called inside constructors or destructors,
because such calls will never go to a more derived class than the caller class.
At this point, the derived class wasn't constructed yet (in the constructor),
or it was destroyed (in the destructor).

When a virtual function is called inside the constructor/destructor,
the compiler ALWAYS uses the base class implementation, but here the
base class function was declared as pure virtual, so it was undefined.

But this isn't the only problem, at the moment the C++ API is very dangerous,
the copy operators/constructors must be explicitly coded or disabled.
The exception class must be specialized too.

This patches (see attached files), fixes the virtual function bug at credentials.
I added a noncopyable base class, and all classes with dangerous copy
operator/constructor derive now from it. This is a quick fix, until they
will be coded correctly.

I ported the "ex-client2.c" to C++, using the C++ API, and I will try to
port all the examples tomorrow, and I'll test the API more.

I'm interested in the C++ API, and I offer my help to improve it.


Eduardo Villanueva Che.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: exx-client2.cpp
Type: text/x-c++src
Size: 2354 bytes
Desc: not available
URL: </pipermail/attachments/20070213/a8e3ac17/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gnutlsxx.cpp.patch
Type: text/x-patch
Size: 19349 bytes
Desc: not available
URL: </pipermail/attachments/20070213/a8e3ac17/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gnutlsxx.h.patch
Type: text/x-patch
Size: 2054 bytes
Desc: not available
URL: </pipermail/attachments/20070213/a8e3ac17/attachment-0001.bin>


More information about the Gnutls-devel mailing list