Skip to content

Commit e25e4b1

Browse files
authored
fix: Exclude BLOCK_MAXSIZE and OBJECT_MAXSIZE from bounds checking (#1842)
1 parent ca02a7d commit e25e4b1

File tree

117 files changed

+237
-237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+237
-237
lines changed

std/assembly/rt/tcms.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function initLazy(space: Object): Object {
122122
// @ts-ignore: decorator
123123
@global @unsafe
124124
export function __new(size: usize, id: i32): usize {
125-
if (size >= OBJECT_MAXSIZE) throw new Error(E_ALLOCATION_TOO_LARGE);
125+
if (size > OBJECT_MAXSIZE) throw new Error(E_ALLOCATION_TOO_LARGE);
126126
var obj = changetype<Object>(__alloc(OBJECT_OVERHEAD + size) - BLOCK_OVERHEAD);
127127
obj.rtId = id;
128128
obj.rtSize = <u32>size;
@@ -140,7 +140,7 @@ export function __renew(oldPtr: usize, size: usize): usize {
140140
memory.copy(newPtr, oldPtr, min(size, oldObj.rtSize));
141141
return newPtr;
142142
}
143-
if (size >= OBJECT_MAXSIZE) throw new Error(E_ALLOCATION_TOO_LARGE);
143+
if (size > OBJECT_MAXSIZE) throw new Error(E_ALLOCATION_TOO_LARGE);
144144
total -= oldObj.size;
145145
var newPtr = __realloc(oldPtr - OBJECT_OVERHEAD, OBJECT_OVERHEAD + size) + OBJECT_OVERHEAD;
146146
var newObj = changetype<Object>(newPtr - TOTAL_OVERHEAD);

std/assembly/rt/tlsf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ function computeSize(size: usize): usize {
455455

456456
/** Prepares and checks an allocation size. */
457457
function prepareSize(size: usize): usize {
458-
if (size >= BLOCK_MAXSIZE) throw new Error(E_ALLOCATION_TOO_LARGE);
458+
if (size > BLOCK_MAXSIZE) throw new Error(E_ALLOCATION_TOO_LARGE);
459459
return computeSize(size);
460460
}
461461

tests/compiler/call-super.optimized.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,12 +1244,12 @@
12441244
(local $4 i32)
12451245
local.get $1
12461246
i32.const 1073741820
1247-
i32.ge_u
1247+
i32.gt_u
12481248
if
12491249
i32.const 1104
12501250
i32.const 1440
12511251
i32.const 458
1252-
i32.const 30
1252+
i32.const 29
12531253
call $~lib/builtins/abort
12541254
unreachable
12551255
end

tests/compiler/call-super.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,12 +1590,12 @@
15901590
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
15911591
local.get $0
15921592
i32.const 1073741820
1593-
i32.ge_u
1593+
i32.gt_u
15941594
if
15951595
i32.const 80
15961596
i32.const 416
15971597
i32.const 458
1598-
i32.const 30
1598+
i32.const 29
15991599
call $~lib/builtins/abort
16001600
unreachable
16011601
end

tests/compiler/class-implements.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,12 +1600,12 @@
16001600
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
16011601
local.get $0
16021602
i32.const 1073741820
1603-
i32.ge_u
1603+
i32.gt_u
16041604
if
16051605
i32.const 32
16061606
i32.const 368
16071607
i32.const 458
1608-
i32.const 30
1608+
i32.const 29
16091609
call $~lib/builtins/abort
16101610
unreachable
16111611
end

tests/compiler/class-overloading.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,12 +1606,12 @@
16061606
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
16071607
local.get $0
16081608
i32.const 1073741820
1609-
i32.ge_u
1609+
i32.gt_u
16101610
if
16111611
i32.const 64
16121612
i32.const 400
16131613
i32.const 458
1614-
i32.const 30
1614+
i32.const 29
16151615
call $~lib/builtins/abort
16161616
unreachable
16171617
end

tests/compiler/class.optimized.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,12 +1251,12 @@
12511251
(local $4 i32)
12521252
local.get $1
12531253
i32.const 1073741820
1254-
i32.ge_u
1254+
i32.gt_u
12551255
if
12561256
i32.const 1056
12571257
i32.const 1392
12581258
i32.const 458
1259-
i32.const 30
1259+
i32.const 29
12601260
call $~lib/builtins/abort
12611261
unreachable
12621262
end

tests/compiler/class.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,12 +1702,12 @@
17021702
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
17031703
local.get $0
17041704
i32.const 1073741820
1705-
i32.ge_u
1705+
i32.gt_u
17061706
if
17071707
i32.const 32
17081708
i32.const 368
17091709
i32.const 458
1710-
i32.const 30
1710+
i32.const 29
17111711
call $~lib/builtins/abort
17121712
unreachable
17131713
end

tests/compiler/constructor.optimized.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,12 +1312,12 @@
13121312
(local $4 i32)
13131313
local.get $1
13141314
i32.const 1073741820
1315-
i32.ge_u
1315+
i32.gt_u
13161316
if
13171317
i32.const 1056
13181318
i32.const 1392
13191319
i32.const 458
1320-
i32.const 30
1320+
i32.const 29
13211321
call $~lib/builtins/abort
13221322
unreachable
13231323
end

tests/compiler/constructor.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,12 +1600,12 @@
16001600
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
16011601
local.get $0
16021602
i32.const 1073741820
1603-
i32.ge_u
1603+
i32.gt_u
16041604
if
16051605
i32.const 32
16061606
i32.const 368
16071607
i32.const 458
1608-
i32.const 30
1608+
i32.const 29
16091609
call $~lib/builtins/abort
16101610
unreachable
16111611
end

tests/compiler/do.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,12 +2003,12 @@
20032003
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
20042004
local.get $0
20052005
i32.const 1073741820
2006-
i32.ge_u
2006+
i32.gt_u
20072007
if
20082008
i32.const 64
20092009
i32.const 400
20102010
i32.const 458
2011-
i32.const 30
2011+
i32.const 29
20122012
call $~lib/builtins/abort
20132013
unreachable
20142014
end

tests/compiler/empty-exportruntime.optimized.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,12 +1262,12 @@
12621262
(local $4 i32)
12631263
local.get $1
12641264
i32.const 1073741820
1265-
i32.ge_u
1265+
i32.gt_u
12661266
if
12671267
i32.const 1056
12681268
i32.const 1392
12691269
i32.const 458
1270-
i32.const 30
1270+
i32.const 29
12711271
call $~lib/builtins/abort
12721272
unreachable
12731273
end

tests/compiler/empty-exportruntime.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,12 +1596,12 @@
15961596
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
15971597
local.get $0
15981598
i32.const 1073741820
1599-
i32.ge_u
1599+
i32.gt_u
16001600
if
16011601
i32.const 32
16021602
i32.const 368
16031603
i32.const 458
1604-
i32.const 30
1604+
i32.const 29
16051605
call $~lib/builtins/abort
16061606
unreachable
16071607
end

tests/compiler/empty-new.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,12 +1589,12 @@
15891589
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
15901590
local.get $0
15911591
i32.const 1073741820
1592-
i32.ge_u
1592+
i32.gt_u
15931593
if
15941594
i32.const 32
15951595
i32.const 368
15961596
i32.const 458
1597-
i32.const 30
1597+
i32.const 29
15981598
call $~lib/builtins/abort
15991599
unreachable
16001600
end

tests/compiler/exports.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,12 +1653,12 @@
16531653
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
16541654
local.get $0
16551655
i32.const 1073741820
1656-
i32.ge_u
1656+
i32.gt_u
16571657
if
16581658
i32.const 32
16591659
i32.const 368
16601660
i32.const 458
1661-
i32.const 30
1661+
i32.const 29
16621662
call $~lib/builtins/abort
16631663
unreachable
16641664
end

tests/compiler/exportstar-rereexport.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,12 +1634,12 @@
16341634
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
16351635
local.get $0
16361636
i32.const 1073741820
1637-
i32.ge_u
1637+
i32.gt_u
16381638
if
16391639
i32.const 80
16401640
i32.const 416
16411641
i32.const 458
1642-
i32.const 30
1642+
i32.const 29
16431643
call $~lib/builtins/abort
16441644
unreachable
16451645
end

tests/compiler/extends-baseaggregate.optimized.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,12 +1258,12 @@
12581258
(local $4 i32)
12591259
local.get $1
12601260
i32.const 1073741820
1261-
i32.ge_u
1261+
i32.gt_u
12621262
if
12631263
i32.const 1216
12641264
i32.const 1552
12651265
i32.const 458
1266-
i32.const 30
1266+
i32.const 29
12671267
call $~lib/builtins/abort
12681268
unreachable
12691269
end

tests/compiler/extends-baseaggregate.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,12 +1598,12 @@
15981598
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
15991599
local.get $0
16001600
i32.const 1073741820
1601-
i32.ge_u
1601+
i32.gt_u
16021602
if
16031603
i32.const 192
16041604
i32.const 528
16051605
i32.const 458
1606-
i32.const 30
1606+
i32.const 29
16071607
call $~lib/builtins/abort
16081608
unreachable
16091609
end

tests/compiler/extends-recursive.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,12 +1594,12 @@
15941594
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
15951595
local.get $0
15961596
i32.const 1073741820
1597-
i32.ge_u
1597+
i32.gt_u
15981598
if
15991599
i32.const 32
16001600
i32.const 368
16011601
i32.const 458
1602-
i32.const 30
1602+
i32.const 29
16031603
call $~lib/builtins/abort
16041604
unreachable
16051605
end

tests/compiler/features/simd.optimized.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,12 +747,12 @@
747747
(local $4 i32)
748748
local.get $1
749749
i32.const 1073741820
750-
i32.ge_u
750+
i32.gt_u
751751
if
752752
i32.const 1120
753753
i32.const 1056
754754
i32.const 458
755-
i32.const 30
755+
i32.const 29
756756
call $~lib/builtins/abort
757757
unreachable
758758
end

tests/compiler/features/simd.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,12 +928,12 @@
928928
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
929929
local.get $0
930930
i32.const 1073741820
931-
i32.ge_u
931+
i32.gt_u
932932
if
933933
i32.const 96
934934
i32.const 32
935935
i32.const 458
936-
i32.const 30
936+
i32.const 29
937937
call $~lib/builtins/abort
938938
unreachable
939939
end

tests/compiler/field-initialization.optimized.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,12 +1264,12 @@
12641264
(local $4 i32)
12651265
local.get $1
12661266
i32.const 1073741820
1267-
i32.ge_u
1267+
i32.gt_u
12681268
if
12691269
i32.const 1056
12701270
i32.const 1392
12711271
i32.const 458
1272-
i32.const 30
1272+
i32.const 29
12731273
call $~lib/builtins/abort
12741274
unreachable
12751275
end

tests/compiler/field-initialization.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,12 +1598,12 @@
15981598
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
15991599
local.get $0
16001600
i32.const 1073741820
1601-
i32.ge_u
1601+
i32.gt_u
16021602
if
16031603
i32.const 32
16041604
i32.const 368
16051605
i32.const 458
1606-
i32.const 30
1606+
i32.const 29
16071607
call $~lib/builtins/abort
16081608
unreachable
16091609
end

tests/compiler/for.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,12 +2016,12 @@
20162016
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
20172017
local.get $0
20182018
i32.const 1073741820
2019-
i32.ge_u
2019+
i32.gt_u
20202020
if
20212021
i32.const 64
20222022
i32.const 400
20232023
i32.const 458
2024-
i32.const 30
2024+
i32.const 29
20252025
call $~lib/builtins/abort
20262026
unreachable
20272027
end

tests/compiler/function-call.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,12 +1625,12 @@
16251625
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
16261626
local.get $0
16271627
i32.const 1073741820
1628-
i32.ge_u
1628+
i32.gt_u
16291629
if
16301630
i32.const 256
16311631
i32.const 592
16321632
i32.const 458
1633-
i32.const 30
1633+
i32.const 29
16341634
call $~lib/builtins/abort
16351635
unreachable
16361636
end

tests/compiler/function-expression.untouched.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,12 +1781,12 @@
17811781
(func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32)
17821782
local.get $0
17831783
i32.const 1073741820
1784-
i32.ge_u
1784+
i32.gt_u
17851785
if
17861786
i32.const 576
17871787
i32.const 912
17881788
i32.const 458
1789-
i32.const 30
1789+
i32.const 29
17901790
call $~lib/builtins/abort
17911791
unreachable
17921792
end

0 commit comments

Comments
 (0)