|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
recursionI have a routine that has worked for years on 32-bit systems, using
crypto++ 5.2.1. I just updated to crypto++ 5.6.0, compiled for 32-bits (Linux; g++ 4.2), and it seems to work fine. I then built the same code on a 64-bit system. crypto++ passes the cryptest.exe tests just fine, BUT... when I run my routine it seems to enter an infinite recursion and eventually segfaults. Looking under gdb, the recursion is between two lines in cryptlib.cpp: lines 260 and 274. The relevant portion of the file is: ---- void RandomNumberGenerator::GenerateBlock(byte *output, size_t size) { ArraySink s(output, size); *LINE 260 GenerateIntoBufferedTransformation(s, DEFAULT_CHANNEL, size); } void RandomNumberGenerator::DiscardBytes(size_t n) { GenerateIntoBufferedTransformation(TheBitBucket(), DEFAULT_CHANNEL, n); } void RandomNumberGenerator::GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword length) { FixedSizeSecBlock<byte, 256> buffer; while (length) { size_t len = UnsignedMin(buffer.size(), length); *LINE 274 GenerateBlock(buffer, len); target.ChannelPut(channel, buffer, len); length -= len; } } ---- It seems quite clear (I think, although maybe I'm being blind somehow) how, once one hits line 260, one can enter a state of infinite recursion, flipping between line 260 and line 274. My question is: how is this supposed to work without recursing infinitely? Doc -- Web: http://www.sff.net/people/N7DR |
|
|
RE: recursion> Date: Fri, 25 Sep 2009 16:53:35 -0600 > From: N7DR@... > To: cryptopp-users@... > Subject: recursion > > I have a routine that has worked for years on 32-bit systems, using > crypto++ 5.2.1. > > I just updated to crypto++ 5.6.0, compiled for 32-bits (Linux; g++ 4.2), > and it seems to work fine. > > I then built the same code on a 64-bit system. crypto++ passes the > cryptest.exe tests just fine, BUT... > > when I run my routine it seems to enter an infinite recursion and > eventually segfaults. > > Looking under gdb, the recursion is between two lines in cryptlib.cpp: > lines 260 and 274. > > The relevant portion of the file is: > > ---- > > void RandomNumberGenerator::GenerateBlock(byte *output, size_t size) > { > ArraySink s(output, size); > *LINE 260 GenerateIntoBufferedTransformation(s, DEFAULT_CHANNEL, size); > } > > void RandomNumberGenerator::DiscardBytes(size_t n) > { > GenerateIntoBufferedTransformation(TheBitBucket(), DEFAULT_CHANNEL, n); > } > > void > RandomNumberGenerator::GenerateIntoBufferedTransformation(BufferedTransformation > &target, const std::string &channel, lword length) > { > FixedSizeSecBlock<byte, 256> buffer; > while (length) > { > size_t len = UnsignedMin(buffer.size(), length); > *LINE 274 GenerateBlock(buffer, len); > target.ChannelPut(channel, buffer, len); > length -= len; > } > } > > ---- > > It seems quite clear (I think, although maybe I'm being blind somehow) how, > once one hits line 260, one can enter a state of infinite recursion, > flipping between line 260 and line 274. > > My question is: how is this supposed to work without recursing infinitely? > > Doc > > -- > Web: http://www.sff.net/people/N7DR > Hotmail® has ever-growing storage! Don’t worry about storage limits. Check it out. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to cryptopp-users-unsubscribe@.... More information about Crypto++ and this group is available at http://www.cryptopp.com. -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: recursionWei Dai said the following at 09/25/2009 09:31 PM :
> The class derived from RandomNumberGenerator is supposed to override one > of those functions. You need to figure out why that's not happening. > Ah! The prototype signature for RandomNumberGenerator::GenerateBlock() changed between 5.2.1 and 5.6.0. Consequently my GenerateBlock(byte *, unsigned int) [which was the old prototype signature (of course it's obvious why it had to be changed, although I'm not sure why there are no "const"s in the signature)] no longer overrides the function. I wonder if there's a tool to automate finding such changes to prototype signatures? It seems very easy to get bitten by this. I would never have discovered that my function wasn't overriding the default if it hadn't led to a crash. Does anyone know of a way to automate finding such changes? I really would rather not go through every single signature manually trying to look for changes :-( Doc -- Web: http://www.sff.net/people/N7DR |
|
|
Re: recursion> I wonder if there's a tool to automate finding such changes to prototype > signatures? It seems very easy to get bitten by this. I would never have > discovered that my function wasn't overriding the default if it hadn't led > to a crash. Does anyone know of a way to automate finding such changes? > > I really would rather not go through every single signature manually trying > to look for changes :-( That's C++ for you :). You could add a call to base implementation after last return so it won't compile if base method suddenly disappears, but that's lots of manual work and will still miss changes that are automatically convertible. And I highly doubt anything can parse C++ good enough to detect it without compiling... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to cryptopp-users-unsubscribe@.... More information about Crypto++ and this group is available at http://www.cryptopp.com. -~----------~----~----~----~------~----~------~--~--- |
| Free embeddable forum powered by Nabble | Forum Help |