Closed Bug 460886 Opened 16 years ago Closed 16 years ago

TM: "Assertion failure: end >= begin" with .substring()

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
critical

Tracking

()

VERIFIED FIXED

People

(Reporter: jruderman, Assigned: mrbkap)

Details

(Keywords: assertion, testcase, verified1.9.1, Whiteboard: [sg:critical?])

Attachments

(3 files, 1 obsolete file)

js -j 
js> for (var j = 0; j < 5; ++j) { "".substring(5); }

Assertion failure: end >= begin, at jsstr.cpp:796

js -j 
for (var j = 0; j < 5; ++j) { "".substring(-60000); } 

Crash [@ js_NewStringCopy] with the invalid memory address being some function of the number in the testcase.
Flags: blocking1.9.1?
Whiteboard: [sg:critical?]
Attached patch Fix (obsolete) — Splinter Review
Ewww. That swap at the end of SubstringTail is really ugly.
Assignee: general → mrbkap
Status: NEW → ASSIGNED
Attachment #344003 - Flags: review?(brendan)
Comment on attachment 344003 [details] [diff] [review]
Fix

> #ifdef JS_TRACER
> static JSString* FASTCALL
> String_p_substring(JSContext* cx, JSString* str, int32 begin, int32 end)
> {
>-    JS_ASSERT(end >= begin);
>     JS_ASSERT(JS_ON_TRACE(cx));
>-    return js_NewDependentString(cx, str, (size_t)begin, (size_t)(end - begin));
>+
>+    int32 length = JSSTRING_LENGTH(str);

Not int32 -- size_t (consolidate the widening to jsdouble within SubstringTail).

>+    return SubstringTail(cx, str, length, begin, end);
> }
> 
> static JSString* FASTCALL
> String_p_substring_1(JSContext* cx, JSString* str, int32 begin)
> {
>-    int32 end = JSSTRING_LENGTH(str);
>-    JS_ASSERT(end >= begin);
>     JS_ASSERT(JS_ON_TRACE(cx));
>-    return js_NewDependentString(cx, str, (size_t)begin, (size_t)(end - begin));
>+
>+    int32 length = JSSTRING_LENGTH(str);

Ditto.

> function testif() {
>-	var q = 0;
>-	for (var i = 0; i < 100; i++) {
>-		if ((i & 1) == 0)
>-			q++;
>-		else
>-			q--;
>-	}
>+        var q = 0;
>+        for (var i = 0; i < 100; i++) {
>+                if ((i & 1) == 0)
>+                        q++;
>+                else
>+                        q--;
>+        }

Overindented! What happened?

You sure you want all that trace-tests.js blame?

/be
(In reply to comment #2)
> Overindented! What happened?

Half of trace-tests.js expects tabstop=4 and half of it expects tabstop=8. I'll revert those changes because it's not worth going back through now.
Attachment #344003 - Attachment is obsolete: true
Attachment #344185 - Flags: review?(brendan)
Attachment #344003 - Flags: review?(brendan)
Attachment #344185 - Flags: review?(brendan) → review+
http://hg.mozilla.org/tracemonkey/rev/35c34996d80e
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
the trace-test.js portion has been added to js1_8_1/trace/trace-test.js
I could not reproduce with either testcase.
Flags: in-testsuite+
Flags: in-litmus-
verified no failures mozilla-central, tracemonkey modulo comment 8
Status: RESOLVED → VERIFIED
Flags: blocking1.9.1? → blocking1.9.1+
Keywords: fixed1.9.1
v 1.9.1, 1.9.2
Group: core-security
Flags: wanted1.9.0.x-
test checked into 1.9.0, 1.9.1, 1.9.2, tracemonkey. 1.9.3 will get picked up in the next merge.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: