File tree Expand file tree Collapse file tree 3 files changed +60
-4
lines changed Expand file tree Collapse file tree 3 files changed +60
-4
lines changed Original file line number Diff line number Diff line change @@ -2034,10 +2034,16 @@ namespace Js
2034
2034
ArenaAllocator * allocator = nullptr ;
2035
2035
2036
2036
#define ACQUIRE_TEMP_GUEST_ALLOCATOR (allocator, scriptContext, name ) \
2037
- tempGuest##allocator = scriptContext->GetTemporaryGuestAllocator (name); \
2038
- allocator = tempGuest##allocator->GetAllocator ();
2037
+ TryFinally ([&]() \
2038
+ { \
2039
+ tempGuest##allocator = scriptContext->GetTemporaryGuestAllocator (name); \
2040
+ allocator = tempGuest##allocator->GetAllocator ();
2039
2041
2040
2042
#define RELEASE_TEMP_GUEST_ALLOCATOR (allocator, scriptContext ) \
2041
- if (tempGuest##allocator) \
2042
- scriptContext->ReleaseTemporaryGuestAllocator (tempGuest##allocator);
2043
+ }, \
2044
+ [&](bool /* hasException*/ ) \
2045
+ { \
2046
+ if (tempGuest##allocator) \
2047
+ scriptContext->ReleaseTemporaryGuestAllocator (tempGuest##allocator); \
2048
+ });
2043
2049
Original file line number Diff line number Diff line change
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
+ // OS18321215: Typed array functions need to release the guest arena if errors happen.
7
+ // This is added as a seperate file and doesn't use the unittestframework as the test depends
8
+ // on certain GC behavior that doesn't trigger otherwise.
9
+ try
10
+ {
11
+ // Type error in filter function
12
+ WScript . LoadModule ( `;` ) ;
13
+ ( async ( ) => {
14
+ testArray1 = new Float32Array ( 1 ) ;
15
+ testArray1 . filter ( function ( ) {
16
+ // type error here
17
+ ArrayBuffer ( ) ;
18
+ } ) ;
19
+ } ) ( ) . then ( ) ;
20
+ / x / , / x / , / x / , / x / ;
21
+ }
22
+ catch ( e ) { }
23
+
24
+ try
25
+ {
26
+ // Type error in filter function
27
+ WScript . LoadModule ( `` ) ;
28
+ for ( var foo = 0 ; / x / g && 0 ; ) {
29
+ }
30
+ / x / g;
31
+ / x / g;
32
+ try {
33
+ testArray2 = new Float64Array ( 1 ) ;
34
+ testArray2 . filter ( function ( ) {
35
+ // type error here
36
+ ArrayBuffer ( ) ;
37
+ } ) ;
38
+ } catch ( e ) {
39
+ }
40
+ function bar ( baz = / x / g) {
41
+ }
42
+ }
43
+ catch ( e ) { }
44
+
45
+ console . log ( "PASS" ) ;
Original file line number Diff line number Diff line change @@ -412,4 +412,9 @@ Below test fails with difference in space. Investigate the cause and re-enable t
412
412
<files >typeofDetached.js</files >
413
413
</default >
414
414
</test >
415
+ <test >
416
+ <default >
417
+ <files >bug18321215.js</files >
418
+ </default >
419
+ </test >
415
420
</regress-exe >
You can’t perform that action at this time.
0 commit comments