-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 7 Nov 2002 at 14:42, Wei Dai wrote:
> It's probably a bug in the GCC optimizer. Please try to track down which
> piece of code is causing the segv, and disable optimization on it. If you
> can't figure it out, let me know and I'll look into it myself.
>
Wei Dei, you may remember that I sent you a private e-mail pointing to
xorbuf as the place where the SEGV was occurring.
Here seems to be another problem associated with performing a release
build.
I have just discovered (the hard way) another simple program that crashes --
in this case even with no optimisation (i.e., no -O flags), but if NDEBUG
is defined in the crypto++ build.
In this case, the crash occurs in DES::Base::UncheckedSetKey while
executing the constructor for
CryptoPP::CBC_Mode<CryptoPP::DES_EDE3>::Encryption.
The source code I used to generate this crash:
int main(void)
{ try
{ unsigned char* key = new unsigned char [24];
unsigned char* plaintext = new unsigned char [192];
unsigned char* iv = new unsigned char [8];
unsigned char* ciphertext = new unsigned char [192];
CryptoPP::CBC_Mode<CryptoPP::DES_EDE3>::Encryption var(key, 24, iv);
var.ProcessData(ciphertext, plaintext, 192); // never gets here
}
catch (...)
{ cout << "Exception caught" << endl; // never gets here
}
return 1;
}
The code works fine if NDEBUG is not defined.
This is using g++ 3.2 under Mandrake Linux 9.0 (i.e., latest versions of
Mandrake Linux and g++).
Trying to trace through this crash, it looks like the problem is that in
secblock.h at line 239, the value of m_ptr is something silly (like 0x20 in
the example I have open in another window right now). I note that the value
of the parameter to the assertion in that line is true (to my surprise,
since I assumed that because NDEBUG controls this crash, the problem would
be in the assertion).
So when the program tries to access m_ptr[index] (index == 0 in the trace I
have open), the program does a SEGV, because of the silly value of m_ptr.
Doc
-----BEGIN PGP SIGNATURE-----
Version: PGP 6.0.2 -- QDPGP 2.60
Comment: Key obtainable from servers: ID 0x362912B8
iQA/AwUBPeZpOGnXrLw2KRK4EQJ8OQCdER3bwKHyDoVZ/2x4NRnPu2T3DU4AnAtr
zPTnXvwPkhL3MrE37tulVGsa
=6J+u
-----END PGP SIGNATURE-----