Re: Segfaults on FreeBSD
Jeffrey Walton <[email protected]>
| Newsgroups | gmane.comp.encryption.cryptopp |
|---|---|
| Message-ID | <CAH8yC8nKGxfW_CrBXQw08C3wZeFKGpG=ZAFG+_1CG-Qu_a3hcg@mail.gmail.com> |
On Tue, May 4, 2021 at 2:08 PM Rogier <[email protected]> wrote: > > I keep getting segfaults within cryptopp on freebsd for at least PBKDF DeriveKey(). I used the sample code from the wiki: > https://www.cryptopp.com/wiki/PKCS12_PBKDF > > I used the cryptopp-lib that is available through the binary ports collection (pkg). The reported version is 8.5.0 > > Any ideas on how I can fix this or at least where to look? > > Below all the technical info about versions and traces for a first triage. Ugh... I can duplicate this, too using FreeBSD's version of the library. It looks like the problem is at frame 3: #3 0x0000000000207739 in CryptoPP::HashTransformation::CalculateDigest ( this=0x7fffffffe820, digest=0x800253000 "", input=<optimized out>, length=192) at /usr/local/include/cryptopp/cryptlib.h:1189 No locals. length=192 is wrong, if I am not mistaken. When I look at frame 4, where 192 is passed to frame 3: (gdb) f 4 #4 CryptoPP::PKCS12_PBKDF<CryptoPP::SHA256>::DeriveKey (this=<optimized out>, derived=0x7fffffffe9a0 "\320`\263", derivedLen=32, purpose=<optimized out>, secret=<optimized out>, secretLen=8, salt=0x7fffffffeac0 "salt", saltLen=4, iterations=1024, timeInSeconds=0) at /usr/local/include/cryptopp/pwdbased.h:439 439 hash.CalculateDigest(Ai, buffer, buffer.size()); (gdb) p Ai $3 = { m_alloc = {<CryptoPP::AllocatorBase<unsigned char>> = {<No data fields>}, <No data fields>}, m_mark = 18446744073709551615, m_size = 32, m_ptr = 0x800253000 ""} So the size looks OK at frame 4. On the upside, building Crypto++ 8.5 from sources is OK and tests OK. I can't duplicate when using Crypto++ 8.5 or Master. It is OK with both the static lib and shared lib. I would be interested to know how FreeBSD builds the library. Like are they using LTO, which is known bad. Every distro I have seen that uses LTO has problems with it. Also see https://cryptopp.com/wiki/Link_Time_Optimization. Is there any chance you can avoid FreeBSD's version, and build Crypto++ yourself? Jeff -- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/CAH8yC8nKGxfW_CrBXQw08C3wZeFKGpG%3DZAFG%2B_1CG-Qu_a3hcg%40mail.gmail.com.