I don't even understand the code - but based on your symptoms (works until you 
increase the level of compiler optimization), I'd say it's a compiler bug. More 
so, a bug in a compiler that's most likely been fixed a long time ago.

Thus, incentive to mess with something that long lost its relevance is pretty 
low. 

Feel free to create and post a reproducer - a small example that compiles and 
demonstrates the problem, if you want to pursue this. Or just upgrade the 
compiler (should be done regardless - your development is insecure).

> On Apr 18, 2021, at 23:07, Sunandan Nandi <sunandan.na...@gmail.com> wrote:
> 
> 
> Hi Uri,
> 
> Thanks.OS version and clang version is project binding right now. But 
> certainly, will check.
> 
> Do you see any obvious problem in the code snippet I have added in the above 
> post?
> 
> Regards,
> Sunandan
> 
>> On Sun, Apr 18, 2021 at 5:45 PM Uri Blumenthal <mouse...@gmail.com> wrote:
>> Considering that the current stable version of Clang is 11, would or not 
>> make sense to upgrade your compiler?
>> 
>> Not to mention that your OS probably does not get any security patches now - 
>> so, perhaps, moving from 18.04LTS to 20.04 LTS would be a good idea?
>> 
>> I regularly build with Clang and GCC, no crashes.
>> 
>>>> On Apr 18, 2021, at 08:02, Sunandan Nandi <sunandan.na...@gmail.com> wrote:
>>>> 
>>> Hi,
>>> 
>>> I am experiencing Segfault inside CryptoPP::StreamTransformationFilter.
>>> 
>>> Overview:
>>> I have downloaded and built CryptoPP as an external CMake module. 
>>> Problem:
>>> This segfault is happening only in Linux(Ubuntu 18.04.05LTS) Release build.
>>> 64-bit,compiler clang 6.0
>>> 
>>> GDB BT
>>> Thread 9 "***" received signal SIGSEGV, Segmentation fault.
>>> [Switching to Thread 0x7fffdb7fe700 (LWP 5835)]
>>> 0x0000000000000000 in ?? ()
>>> (gdb) bt
>>> #0  0x0000000000000000 in ?? ()
>>> #1  0x0000000000b7559d in 
>>> CryptoPP::StreamTransformationFilter::StreamTransformationFilter 
>>> (this=0x7fffdb7fd1c0, c=..., attachment=<optimized out>,
>>>     padding=<optimized out>) at filters.cpp:593
>>> #2  0x00000000004ff4fd in 
>>> ***::AESEncryptDecryptUtility::decrypt(std::__cxx11::basic_string<char, 
>>> std::char_traits<char>, std::allocator<char> > const&) ()
>>> 
>>> Trials to resolve this issue:
>>> If I build my target where I am using CryptoPP( static lib) with 
>>> optimization level O1 or less, then no segfault observed. But this issue is 
>>> with optimization level O2 or more.
>>> 
>>> Code snippet:
>>> std::string AESEncryptDecryptUtility::decrypt(const std::string& 
>>> encrypted_text) { std::string decrypted_text; CryptoPP::AES::Decryption 
>>> aesDecryption(key_.data(), KEY_LENGTH); 
>>> CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption(aesDecryption, 
>>> iv_.data()); CryptoPP::StreamTransformationFilter 
>>> stfDecryptor(cbcDecryption, new CryptoPP::StringSink(decrypted_text)); 
>>> stfDecryptor.Put(reinterpret_cast<const unsigned 
>>> char*>(encrypted_text.c_str()), encrypted_text.size()); 
>>> stfDecryptor.MessageEnd(); return decrypted_text; 
>>> 
>>> Inside StreamTransformationFilter() where it's crashing, the line 
>>> highlighted in Red is pointing in GDB as the last point before the 
>>> crash(segfault)
>>> 
>>> StreamTransformationFilter::StreamTransformationFilter(StreamTransformation 
>>> &c, BufferedTransformation *attachment, BlockPaddingScheme padding)
>>>     : FilterWithBufferedInput(attachment), m_cipher(c), 
>>> m_padding(DEFAULT_PADDING)
>>> {
>>>     CRYPTOPP_ASSERT(c.MinLastBlockSize() == 0 || c.MinLastBlockSize() > 
>>> c.MandatoryBlockSize());
>>> 
>>>     const bool authenticatedFilter = 
>>> dynamic_cast<AuthenticatedSymmetricCipher *>(&c) != NULLPTR;
>>>     if (authenticatedFilter)
>>>         throw InvalidArgument("StreamTransformationFilter: please use 
>>> AuthenticatedEncryptionFilter and AuthenticatedDecryptionFilter for 
>>> AuthenticatedSymmetricCipher");
>>> 
>>>     // InitializeDerivedAndReturnNewSizes may override some of these
>>>     m_mandatoryBlockSize = m_cipher.MandatoryBlockSize();
>>> 
>>> Please let me know if any other information needed.
>>> 
>>> Regards,
>>> Sunandan
>>> 
>>>  
>>> -- 
>>> 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 cryptopp-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/cryptopp-users/e6c860f6-1e74-4372-b4de-691e0692747bn%40googlegroups.com.
>> 
>> -- 
>> 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 cryptopp-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/cryptopp-users/17A2AD5B-284E-406B-8C8E-EAB3F80F85B5%40gmail.com.
> 
> -- 
> 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 cryptopp-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/cryptopp-users/CAKPYA22Gv%3Dr_HNg3j3Dom_E4yRcv6eH6sDX%2B2qbRrkT9vT4W1A%40mail.gmail.com.

-- 
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 cryptopp-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/cryptopp-users/432B0DA5-BC99-4F43-887C-3C8BA578B9D0%40gmail.com.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to