- Revision
- 208567
- Author
- jfbast...@apple.com
- Date
- 2016-11-10 15:07:15 -0800 (Thu, 10 Nov 2016)
Log Message
ASSERTION FAILED: length > offset encountered with wasm.yaml/wasm/js-api/test_Module.js.default-wasm
https://bugs.webkit.org/show_bug.cgi?id=164597
Reviewed by Keith Miller.
JSTests:
Trim the array buffer before returning it: it's optimistically
over-allocated to avoid growing all the time, but when parsed it
can't have extra content.
* wasm/Builder_WebAssemblyBinary.js:
(export.const.Binary):
* wasm/LowLevelBinary.js:
(export.default.LowLevelBinary.prototype.get return):
Source/_javascript_Core:
* wasm/WasmParser.h:
(JSC::Wasm::Parser::parseVarUInt32): move closer to other parsers
(JSC::Wasm::Parser::parseVarUInt64): move closer to other parsers
Source/WTF:
Decoding at end of file should fail, not assert.
* wtf/LEBDecoder.h:
(WTF::LEBDecoder::decodeUInt):
(WTF::LEBDecoder::decodeInt32):
Modified Paths
Diff
Modified: trunk/JSTests/ChangeLog (208566 => 208567)
--- trunk/JSTests/ChangeLog 2016-11-10 23:03:28 UTC (rev 208566)
+++ trunk/JSTests/ChangeLog 2016-11-10 23:07:15 UTC (rev 208567)
@@ -1,3 +1,19 @@
+2016-11-10 JF Bastien <jfbast...@apple.com>
+
+ ASSERTION FAILED: length > offset encountered with wasm.yaml/wasm/js-api/test_Module.js.default-wasm
+ https://bugs.webkit.org/show_bug.cgi?id=164597
+
+ Reviewed by Keith Miller.
+
+ Trim the array buffer before returning it: it's optimistically
+ over-allocated to avoid growing all the time, but when parsed it
+ can't have extra content.
+
+ * wasm/Builder_WebAssemblyBinary.js:
+ (export.const.Binary):
+ * wasm/LowLevelBinary.js:
+ (export.default.LowLevelBinary.prototype.get return):
+
2016-11-10 Joseph Pecoraro <pecor...@apple.com>
test262: DataView / TypedArray methods should throw RangeErrors for negative numbers (ToIndex)
Modified: trunk/JSTests/wasm/Builder_WebAssemblyBinary.js (208566 => 208567)
--- trunk/JSTests/wasm/Builder_WebAssemblyBinary.js 2016-11-10 23:03:28 UTC (rev 208566)
+++ trunk/JSTests/wasm/Builder_WebAssemblyBinary.js 2016-11-10 23:07:15 UTC (rev 208567)
@@ -103,5 +103,6 @@
}
sectionBin.apply();
}
+ wasmBin.trim();
return wasmBin;
};
Modified: trunk/JSTests/wasm/LowLevelBinary.js (208566 => 208567)
--- trunk/JSTests/wasm/LowLevelBinary.js 2016-11-10 23:03:28 UTC (rev 208566)
+++ trunk/JSTests/wasm/LowLevelBinary.js 2016-11-10 23:07:15 UTC (rev 208567)
@@ -76,6 +76,7 @@
// Utilities.
get() { return this._buf; }
hexdump() { return _hexdump(this._buf, this._used); }
+ trim() { this._buf = this._buf.slice(0, this._used); }
_maybeGrow(bytes) {
const allocated = this._buf.length;
if (allocated - this._used < bytes) {
Modified: trunk/Source/_javascript_Core/ChangeLog (208566 => 208567)
--- trunk/Source/_javascript_Core/ChangeLog 2016-11-10 23:03:28 UTC (rev 208566)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-11-10 23:07:15 UTC (rev 208567)
@@ -1,3 +1,14 @@
+2016-11-10 JF Bastien <jfbast...@apple.com>
+
+ ASSERTION FAILED: length > offset encountered with wasm.yaml/wasm/js-api/test_Module.js.default-wasm
+ https://bugs.webkit.org/show_bug.cgi?id=164597
+
+ Reviewed by Keith Miller.
+
+ * wasm/WasmParser.h:
+ (JSC::Wasm::Parser::parseVarUInt32): move closer to other parsers
+ (JSC::Wasm::Parser::parseVarUInt64): move closer to other parsers
+
2016-11-10 Joseph Pecoraro <pecor...@apple.com>
test262: DataView / TypedArray methods should throw RangeErrors for negative numbers (ToIndex)
Modified: trunk/Source/_javascript_Core/wasm/WasmParser.h (208566 => 208567)
--- trunk/Source/_javascript_Core/wasm/WasmParser.h 2016-11-10 23:03:28 UTC (rev 208566)
+++ trunk/Source/_javascript_Core/wasm/WasmParser.h 2016-11-10 23:07:15 UTC (rev 208567)
@@ -46,15 +46,15 @@
bool WARN_UNUSED_RETURN consumeString(const char*);
bool WARN_UNUSED_RETURN consumeUTF8String(String&, size_t);
- bool WARN_UNUSED_RETURN parseVarUInt1(uint8_t& result);
- bool WARN_UNUSED_RETURN parseInt7(int8_t& result);
- bool WARN_UNUSED_RETURN parseUInt7(uint8_t& result);
- bool WARN_UNUSED_RETURN parseUInt32(uint32_t& result);
- bool WARN_UNUSED_RETURN parseVarUInt32(uint32_t& result) { return WTF::LEBDecoder::decodeUInt32(m_source, m_sourceLength, m_offset, result); }
- bool WARN_UNUSED_RETURN parseVarUInt64(uint64_t& result) { return WTF::LEBDecoder::decodeUInt64(m_source, m_sourceLength, m_offset, result); }
+ bool WARN_UNUSED_RETURN parseVarUInt1(uint8_t&);
+ bool WARN_UNUSED_RETURN parseInt7(int8_t&);
+ bool WARN_UNUSED_RETURN parseUInt7(uint8_t&);
+ bool WARN_UNUSED_RETURN parseUInt32(uint32_t&);
+ bool WARN_UNUSED_RETURN parseVarUInt32(uint32_t&);
+ bool WARN_UNUSED_RETURN parseVarUInt64(uint64_t&);
- bool WARN_UNUSED_RETURN parseValueType(Type& result);
- bool WARN_UNUSED_RETURN parseExternalKind(External::Kind& result);
+ bool WARN_UNUSED_RETURN parseValueType(Type&);
+ bool WARN_UNUSED_RETURN parseExternalKind(External::Kind&);
const uint8_t* source() const { return m_source; }
size_t length() const { return m_sourceLength; }
@@ -112,6 +112,16 @@
return true;
}
+ALWAYS_INLINE bool Parser::parseVarUInt32(uint32_t& result)
+{
+ return WTF::LEBDecoder::decodeUInt32(m_source, m_sourceLength, m_offset, result);
+}
+
+ALWAYS_INLINE bool Parser::parseVarUInt64(uint64_t& result)
+{
+ return WTF::LEBDecoder::decodeUInt64(m_source, m_sourceLength, m_offset, result);
+}
+
ALWAYS_INLINE bool Parser::parseUInt32(uint32_t& result)
{
if (length() < 4 || m_offset > length() - 4)
Modified: trunk/Source/WTF/ChangeLog (208566 => 208567)
--- trunk/Source/WTF/ChangeLog 2016-11-10 23:03:28 UTC (rev 208566)
+++ trunk/Source/WTF/ChangeLog 2016-11-10 23:07:15 UTC (rev 208567)
@@ -1,3 +1,16 @@
+2016-11-10 JF Bastien <jfbast...@apple.com>
+
+ ASSERTION FAILED: length > offset encountered with wasm.yaml/wasm/js-api/test_Module.js.default-wasm
+ https://bugs.webkit.org/show_bug.cgi?id=164597
+
+ Reviewed by Keith Miller.
+
+ Decoding at end of file should fail, not assert.
+
+ * wtf/LEBDecoder.h:
+ (WTF::LEBDecoder::decodeUInt):
+ (WTF::LEBDecoder::decodeInt32):
+
2016-11-10 Alex Christensen <achristen...@webkit.org>
Remove unused CFURLCACHE code
Modified: trunk/Source/WTF/wtf/LEBDecoder.h (208566 => 208567)
--- trunk/Source/WTF/wtf/LEBDecoder.h 2016-11-10 23:03:28 UTC (rev 208566)
+++ trunk/Source/WTF/wtf/LEBDecoder.h 2016-11-10 23:07:15 UTC (rev 208567)
@@ -37,7 +37,8 @@
template<size_t maxByteLength, typename T>
inline bool WARN_UNUSED_RETURN decodeUInt(const uint8_t* bytes, size_t length, size_t& offset, T& result)
{
- ASSERT(length > offset);
+ if (length <= offset)
+ return false;
result = 0;
unsigned shift = 0;
size_t last = std::min(maxByteLength, length - offset - 1);
@@ -69,7 +70,8 @@
inline bool WARN_UNUSED_RETURN decodeInt32(const uint8_t* bytes, size_t length, size_t& offset, int32_t& result)
{
- ASSERT(length > offset);
+ if (length <= offset)
+ return false;
result = 0;
unsigned shift = 0;
size_t last = std::min(max32BitLEBByteLength, length - offset - 1);