Hi,
While using MudularArithmetic class of 5.2.1, I encountered a problem.
When I call Add, Multiply, Square functions of the class with very large
numbers (1024bits) as parameters, my program crashes with "double free or
corruption" errors. Looking at the gdb trace, I suspect if this is due to
some errors in SecBlock implementation.
Here is the gdb trace.
-----------------------------------------------------------------------
*** glibc detected *** double free or corruption (out): 0x08238408 ***
Program received signal SIGABRT, Aborted.
0xffffe410 in __kernel_vsyscall ()
(gdb) bt
#0 0xffffe410 in __kernel_vsyscall ()
#1 0xb7cc39b1 in raise () from /lib/tls/i686/cmov/libc.so.6
#2 0xb7cc52c9 in abort () from /lib/tls/i686/cmov/libc.so.6
#3 0xb7cf76ea in __fsetlocking () from /lib/tls/i686/cmov/libc.so.6
#4 0xb7cfdf54 in malloc_trim () from /lib/tls/i686/cmov/libc.so.6
#5 0xb7cfe2ca in free () from /lib/tls/i686/cmov/libc.so.6
#6 0xb7ebfc71 in operator delete () from /usr/lib/libstdc++.so.6
#7 0xb7ebfccc in operator delete[] () from /usr/lib/libstdc++.so.6
#8 0x08086283 in CryptoPP::AllocatorWithCleanup<unsigned int>::deallocate
(this=0xbfe1133c, p=0x8238408, n=2) at secblock.h:95
#9 0x080887c7 in CryptoPP::StandardReallocate<unsigned int,
CryptoPP::AllocatorWithCleanup<unsigned int> > ([EMAIL PROTECTED],
p=0x8238408, oldSize=2,
newSize=4, preserve=false) at secblock.h:71
#10 0x08088815 in CryptoPP::AllocatorWithCleanup<unsigned int>::reallocate
(this=0xbfe1133c, p=0x8238408, oldSize=2, newSize=4, preserve=false)
at secblock.h:100
#11 0x080f4b0d in CryptoPP::SecBlock<unsigned int,
CryptoPP::AllocatorWithCleanup<unsigned int> >::New (this=0xbfe1133c,
newSize=4) at secblock.h:309
#12 0x08117170 in CryptoPP::Integer::operator= (this=0xbfe11338,
[EMAIL PROTECTED]) at integer.cpp:2865
#13 0x0811849c in CryptoPP::ModularArithmetic::Add (this=0xbfe11304,
[EMAIL PROTECTED], [EMAIL PROTECTED]) at integer.cpp:4042
#14 0x0804c732 in MyPolynomialOver::Plus (this=0xbfe10f2c, [EMAIL PROTECTED],
[EMAIL PROTECTED]) at mypolynomi.cpp:260
----------------------------------------------------------------------
The program mypolynomi.cpp is basically, a copy of polynomi.cpp of
cryptopp package -- using ModularArithmetic as its ring. Plus() is
implemented as Plus() of PolynomialOverRing is. The similar problem occurs
sometimes when I have to destroy a stl vector container of Integers --
~Secblock() is called and generates "double free or corruption" error
again. When I use small integers, I didn't have such problems.
I am using cryptopp 5.2.1 + patch for gcc 4.0 compiled with gcc ver 4.0.2.
Any clue?
Thank you!
- Hyang-Ah