[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: GCC5 library transition for xml-security-c -- needed or not?



* Ferenc Wagner <wferi@niif.hu>, 2015-11-29, 22:26:
If you grep for "std::map<std::string", you'll find this in OpenSSLCryptoProvider.hpp:

class DSIG_EXPORT OpenSSLCryptoProvider : public XSECCryptoProvider {
#ifdef XSEC_OPENSSL_HAVE_EC
  std::map<std::string,int> m_namedCurveMap;
#endif

[...]

Now I still fail to follow the last step of your reasoning: how does a change in the internal representaion of curve names (std::string) break the ABI?

In general, changing type of a non-static member of a (public) class constitutes ABI breakage, even if it's a private member.

You could get away from it sometimes, and this might be the case here, so perhaps I was overly pessimistic. :)

I can think of two reasons why changing private member can break ABI in practice:

1) Changing the member type could change its size, leading to changing memory layout of the class. (However, in this case std::map<std::string,int> size didn't change AFAICS.)

2) User of the class could be accessing private members via inlined code. If the user of the class has a different idea about the member type than the library, this is clearly not going to fly.

Now, looking at the OpenSSLCryptoProvider header, it doesn't have any explicitly declared inline methods, constructors, etc. But it does have implicit inline copy constructor and implicit inline assignment operator. So I was able to craft a small test program, which crashes if it was compiled with GCC 4.X (and the library was compiled with GCC 5):

$ g++-5 test.cc -l xml-security-c -o test && ./test
moo!
$ g++-4.9 test.cc -l xml-security-c -o test && ./test
moo!
Segmentation fault

That said, this example is a bit contrived, because OpenSSLCryptoProvider doesn't look like something that is safe to instantiate multiple times anyway.

(Classes that are not supposed to be copied should declare private copy constructors and assignment operators. You might want to ask upstream to add them.)

--
Jakub Wilk
#include <iostream>

#include <xsec/enc/OpenSSL/OpenSSLCryptoProvider.hpp>

int main(int argc, char **argv)
{
	OpenSSLCryptoProvider op;
	OpenSSLCryptoProvider op2(op);
	std::cout << "moo!\n";
}

Reply to: