I had the same problem a few days ago. This happens because CryptoPP::BufferedTransformation::ChannelPut2 is using the static alloc'ed std::string CryptoPP::DEFAULT_CHANNEL (assigned as default argument in CryptoPP::BufferedTransformation::TransferTo ) and this object have not yet been constructed.
Probably its working on another distro because the static initialization is being handled differently by the system. This behavior is known as "the static initialization fiasco" ( http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.14). The best way to resolve this issue is to initialize the static member Domain::domain in the first use (using the construct-on-first-use idiom, as noted in the #10.15 topic of the C++ FAQ ). Best regards, -- Rafael Vargas 2011/10/26 Ignat Korchagin <[email protected]> > I'm getting a segmentation fault when using static libcryptopp.a in > Fedora 15. > > Here is my call stack: > TestStr [C/C++ Application] > /home/test/workspace/TestStr/Debug/TestStr [i1] > Thread [1] (Suspended : Signal : SIGSEGV:Segmentation fault) > std::basic_string<char, std::char_traits<char>, > std::allocator<char> >::empty() at 0x1a5a86 > CryptoPP::BufferedTransformation::ChannelPut2() at > cryptlib.cpp:356 > 0x80ab601 > CryptoPP::StringStore::CopyRangeTo2() at > filters.cpp:1,069 > 0x80becc0 > CryptoPP::StringStore::TransferTo2() at > filters.cpp:1,059 > 0x80bebc8 > CryptoPP::BufferedTransformation::TransferTo() at > cryptlib.h:901 > 0x8054cfd > CryptoPP::BufferedTransformation::Get() at > cryptlib.cpp:420 > 0x80ababf > CryptoPP::BufferedTransformation::Get() at > cryptlib.cpp:410 > 0x80aba23 > CryptoPP::PolynomialMod2::Decode() at gf2n.cpp:152 > 0x804b62c > CryptoPP::PolynomialMod2::Decode() at gf2n.cpp:136 > 0x804b55d > CryptoPP::PolynomialMod2::PolynomialMod2() at > gf2n.h:48 0x804a2d5 > <...more frames...> > > This is my main cpp: > > #include <iostream> > #include "Domain.h" > using namespace std; > > int main() { > cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! > return 0; > } > > And one class Domain.h and Domain.cpp > Domain.h: > > #ifndef _DOMAIN_H_ > #define _DOMAIN_H_ > > #include "ec2n.h" > > class Domain > { > public: > Domain(); > virtual ~Domain(); > CryptoPP::EC2N curve; > CryptoPP::Integer N; > CryptoPP::EC2NPoint basePoint; > static Domain domain; > static const size_t ByteSize=24; > }; > > #endif //_DOMAIN_H_ > > And domain.cpp: > > #include "Domain.h" > > typedef unsigned char uint8_t; > > static uint8_t B[]={0x7B, 0xC8, 0x6E, 0x21, 0x02, 0x90, 0x2E, 0xC4, > 0xD5, 0x89, 0x0E, 0x8B, 0x6B, 0x49, 0x81, 0xff, 0x27, 0xE0, 0x48, > 0x27, 0x50, 0xFE, 0xFC, 0x03}; > static uint8_t n[]={0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, > 0x00, 0x00, 0x00, 0x00, 0x69, 0xA7, 0x79, 0xCA, 0xC1, 0xDA, 0xBC, > 0x67, 0x88, 0xF7, 0x47, 0x4F}; > static uint8_t bpX[]={0x71, 0x41, 0x14, 0xB7, 0x62, 0xF2, 0xFF, 0x4A, > 0x79, 0x12, 0xA6, 0xD2, 0xAC, 0x58, 0xB9, 0xB5, 0xC2, 0xFC, 0xFE, > 0x76, 0xDA, 0xEB, 0x71, 0x29}; > static uint8_t bpY[]={0x29, 0xC4, 0x1E, 0x56, 0x8B, 0x77, 0xC6, 0x17, > 0xEF, 0xE5, 0x90, 0x2F, 0x11, 0xDB, 0x96, 0xFA, 0x96, 0x13, 0xCD, > 0x8D, 0x03, 0xDB, 0x08, 0xDA}; > > > Domain::Domain():curve(CryptoPP::EC2N::Field(CryptoPP::PolynomialMod2::Trinomial(191,9,0)),CryptoPP::EC2N::FieldElement::One(),CryptoPP::EC2N::FieldElement(B,sizeof(B))), > N(n, sizeof(n)), > > basePoint(CryptoPP::PolynomialMod2(bpX,sizeof(bpX)),CryptoPP::PolynomialMod2(bpY,sizeof(bpY))) > { > } > > Domain::~Domain() > { > } > > // Domain member functions > > Domain Domain::domain; > > The fault comes with the construction of the static member > Domain::domain. Tried the same on Fedora Core 6 - works fine. > > Please help. > Ignat > > -- > You received this message because you are subscribed to the "Crypto++ > Users" Google Group. > To unsubscribe, send an email to > [email protected]. > More information about Crypto++ and this group is available at > http://www.cryptopp.com. -- You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to [email protected]. More information about Crypto++ and this group is available at http://www.cryptopp.com.
