Skip to content

Commit af35f26

Browse files
committed
[MERGE #5292 @rajatd] Catching typed array OOB AVs coming from stack allocated functions. OS #17785360
Merge pull request #5292 from rajatd:stackfuncAV
2 parents cb568a8 + e2e570a commit af35f26

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

lib/Runtime/Library/JavascriptFunction.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,12 +1905,11 @@ void __cdecl _alloca_probe_16()
19051905
RecyclerHeapObjectInfo heapObject;
19061906
Recycler* recycler = threadContext->GetRecycler();
19071907

1908-
bool isFuncObjHeapAllocated = recycler->FindHeapObject(func, FindHeapObjectFlags_NoFlags, heapObject); // recheck if this needs to be removed
19091908
bool isEntryPointHeapAllocated = recycler->FindHeapObject(func->GetEntryPointInfo(), FindHeapObjectFlags_NoFlags, heapObject);
19101909
bool isFunctionBodyHeapAllocated = recycler->FindHeapObject(func->GetFunctionBody(), FindHeapObjectFlags_NoFlags, heapObject);
19111910

19121911
// ensure that all our objects are heap allocated
1913-
if (!(isFuncObjHeapAllocated && isEntryPointHeapAllocated && isFunctionBodyHeapAllocated))
1912+
if (!(isEntryPointHeapAllocated && isFunctionBodyHeapAllocated))
19141913
{
19151914
return nullptr;
19161915
}

test/Bugs/bug17785360.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
6+
arr = new Uint8Array(0x40000);
7+
var obj = {x : 1.1};
8+
function test2()
9+
{
10+
return obj.x;
11+
}
12+
function test()
13+
{
14+
function test1()
15+
{
16+
for(var i=0; i < arr.length; i++)
17+
{
18+
arr[i] = arr[i+1] = arr[i+2] = Math.floor(test2() / 4294967295 * 128), arr[i + 3] = 255;
19+
}
20+
}
21+
test1(arr);
22+
}
23+
24+
test();
25+
print("passed");

test/Bugs/rlexe.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,4 +484,9 @@
484484
<compile-flags>-forceNative -forcejitloopbody -off:aggressiveinttypespec -off:ArrayCheckHoist</compile-flags>
485485
</default>
486486
</test>
487+
<test>
488+
<default>
489+
<files>bug17785360.js</files>
490+
</default>
491+
</test>
487492
</regress-exe>

0 commit comments

Comments
 (0)