diff --git a/src/ripple/nodestore/impl/codec.h b/src/ripple/nodestore/impl/codec.h index 4fe4bebb3..5f76ae6fe 100644 --- a/src/ripple/nodestore/impl/codec.h +++ b/src/ripple/nodestore/impl/codec.h @@ -29,6 +29,7 @@ #include #include #include +#include #include namespace ripple { @@ -61,14 +62,14 @@ snappy_decompress (void const* in, reinterpret_cast(in), in_size, &result.second)) Throw ( - "snappy decompress"); + "snappy decompress: GetUncompressedLength"); void* const out = bf(result.second); result.first = out; if (! snappy::RawUncompress( reinterpret_cast(in), in_size, reinterpret_cast(out))) Throw ( - "snappy decompress"); + "snappy decompress: RawUncompress"); return result; } @@ -86,7 +87,7 @@ lz4_decompress (void const* in, p, in_size, result.second); if (n == 0) Throw ( - "lz4 decompress"); + "lz4 decompress: n == 0"); void* const out = bf(result.second); result.first = out; if (LZ4_decompress_fast( @@ -94,7 +95,7 @@ lz4_decompress (void const* in, reinterpret_cast(out), result.second) + n != in_size) Throw ( - "lz4 decompress"); + "lz4 decompress: LZ4_decompress_fast"); return result; } @@ -177,7 +178,9 @@ nodeobject_decompress (void const* in, field::size; // Mask if (in_size < hs + 32) Throw ( - "nodeobject codec: short inner node"); + "nodeobject codec v1: short inner node size: " + + std::string("in_size = ") + std::to_string(in_size) + + " hs = " + std::to_string(hs)); istream is(p, in_size); std::uint16_t mask; read(is, mask); // Mask @@ -193,7 +196,7 @@ nodeobject_decompress (void const* in, static_cast(HashPrefix::innerNode)); if (mask == 0) Throw ( - "nodeobject codec: empty inner node"); + "nodeobject codec v1: empty inner node"); std::uint16_t bit = 0x8000; for (int i = 16; i--; bit >>= 1) { @@ -201,7 +204,9 @@ nodeobject_decompress (void const* in, { if (in_size < 32) Throw ( - "nodeobject codec: short inner node"); + "nodeobject codec v1: short inner node subsize: " + + std::string("in_size = ") + std::to_string(in_size) + + " i = " + std::to_string(i)); std::memcpy(os.data(32), is(32), 32); in_size -= 32; } @@ -212,14 +217,16 @@ nodeobject_decompress (void const* in, } if (in_size > 0) Throw ( - "nodeobject codec: long inner node"); + "nodeobject codec v1: long inner node, in_size = " + + std::to_string(in_size)); break; } case 3: // full v1 inner node { if (in_size != 16 * 32) // hashes Throw ( - "nodeobject codec: short full inner node"); + "nodeobject codec v1: short full inner node, in_size = " + + std::to_string(in_size)); istream is(p, in_size); result.second = 525; void* const out = bf(result.second); @@ -239,7 +246,9 @@ nodeobject_decompress (void const* in, field::size; // Mask size if (in_size < hs + 65) Throw ( - "nodeobject codec: short inner node"); + "nodeobject codec v2: short inner node size: " + + std::string("size = ") + std::to_string(in_size) + + " hs = " + std::to_string(hs)); istream is(p, in_size); std::uint16_t mask; read(is, mask); // Mask @@ -258,7 +267,7 @@ nodeobject_decompress (void const* in, static_cast(HashPrefix::innerNodeV2)); if (mask == 0) Throw ( - "nodeobject codec: empty inner node"); + "nodeobject codec v2: empty inner node"); std::uint16_t bit = 0x8000; for (int i = 16; i--; bit >>= 1) { @@ -266,7 +275,9 @@ nodeobject_decompress (void const* in, { if (in_size < 32) Throw ( - "nodeobject codec: short inner node"); + "nodeobject codec v2: short inner node subsize: " + + std::string("in_size = ") + std::to_string(in_size) + + " i = " + std::to_string(i)); std::memcpy(os.data(32), is(32), 32); in_size -= 32; } @@ -278,12 +289,15 @@ nodeobject_decompress (void const* in, write(os, depth); if (in_size < (depth+1)/2) Throw ( - "nodeobject codec: short inner node"); + "nodeobject codec v2: short inner node: " + + std::string("size = ") + std::to_string(in_size) + + " depth = " + std::to_string(depth)); std::memcpy(os.data((depth+1)/2), is((depth+1)/2), (depth+1)/2); in_size -= (depth+1)/2; if (in_size > 0) Throw ( - "nodeobject codec: long inner node"); + "nodeobject codec v2: long inner node, in_size = " + + std::to_string(in_size)); break; } case 6: // full v2 inner node @@ -295,7 +309,9 @@ nodeobject_decompress (void const* in, result.second = 525 + 1 + (depth+1)/2; if (in_size != 16 * 32 + (depth+1)/2) // hashes and common Throw ( - "nodeobject codec: short full inner node"); + "nodeobject codec v2: short full inner node: " + + std::string("size = ") + std::to_string(in_size) + + " depth = " + std::to_string(depth)); void* const out = bf(result.second); result.first = out; ostream os(out, result.second);