Closed Bug 76976 Opened 24 years ago Closed 24 years ago

RegExp.prototype.lastIndex now stops at 2^30 -1 (was 2^32-1)

Categories

(Core :: JavaScript Engine, defect, P1)

x86
All
defect

Tracking

()

VERIFIED FIXED
mozilla0.9

People

(Reporter: pschwartau, Assigned: brendan)

Details

(Keywords: js1.5)

Attachments

(1 file)

The fix for bug 76233 "Deadlock between regular expressions and GC" is causing js/tests/ecma_2/RegExp/properties-002.js to fail. This test sets regexp.lastIndex to high values: re = /abc/; re.lastIndex = Math.pow(2,31); re.lastIndex = Math.pow(2,32)-1; re.lastIndex = Math.pow(2,31)-1; re.lastIndex = Math.pow(2,30)-1; re.lastIndex = Math.pow(2,30); But it now fails to recover any value higher than 2^30 -1: FAILED! re.lastIndex = 0 expected: 2147483648 FAILED! re.lastIndex = -1 expected: 4294967295 FAILED! re.lastIndex = -1 expected: 2147483647 PASSED! re.lastIndex = 1073741823 PASSED! FAILED! re.lastIndex = undefined expected: 1073741824 If I back out the changes made for bug 76233, the test passes: PASSED! re.lastIndex = 2147483648 PASSED! PASSED! re.lastIndex = 4294967295 PASSED! PASSED! re.lastIndex = 2147483647 PASSED! PASSED! re.lastIndex = 1073741823 PASSED! PASSED! re.lastIndex = 1073741824 PASSED! I observed that re.lastIndex used to cycle at 2^32: js> re.lastIndex=Math.pow(2,32)-1 4294967295 js> re.lastIndex 4294967295 js> re.lastIndex=Math.pow(2,32) 4294967296 js> re.lastIndex 0 Whereas now it is becoming undefined at 2^30: js> var re = /abc/ js> re.lastIndex = Math.pow(2,30)-1 1073741823 js> re.lastIndex 1073741823 js> re.lastIndex = Math.pow(2,30) 1073741824 js> re.lastIndex js> re.lastIndex == undefined true I haven't found any ECMA spec for this, so it may not be a valid bug. In any case, the behavior has changed...
Dammit, my deadlock avoidance change was not supposed to do that. Stupid jsval int domain limits! /be
Assignee: rogerl → brendan
Keywords: js1.5, mozilla0.9.1
Priority: -- → P1
Target Milestone: --- → mozilla0.9.1
Patch coming right up. /be
Status: NEW → ASSIGNED
Attached patch proposed fixSplinter Review
Screw it, I should not have busted this in 0.9. Going for 0.9. /be
Keywords: mozilla0.9.1mozilla0.9
Target Milestone: mozilla0.9.1 → mozilla0.9
Get it into 0.9.
r=shaver. (Who reviewed that silliness? =) )
You and beard reviewed the correct fix, then I checked in the wrong patch! I suck! Thanks. /be
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Verified Fixed with debug, optimized JS shells on WinNT and Linux.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: