Skip to content

Fix TLSF state corruption #1060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions std/assembly/rt/tlsf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,14 +552,10 @@ export function reallocateBlock(root: Root, block: Block, size: usize): Block {
}

// otherwise move the block
var newBlock = allocateBlock(root, size);
var newBlock = allocateBlock(root, size); // may invalidate cached blockInfo
newBlock.rtId = block.rtId;
memory.copy(changetype<usize>(newBlock) + BLOCK_OVERHEAD, changetype<usize>(block) + BLOCK_OVERHEAD, size);
if (changetype<usize>(block) >= __heap_base) {
block.mmInfo = blockInfo | FREE;
insertBlock(root, block);
if (isDefined(ASC_RTRACE)) onfree(block);
}
if (changetype<usize>(block) >= __heap_base) freeBlock(root, block);
return newBlock;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/do.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@
if
i32.const 0
i32.const 64
i32.const 569
i32.const 565
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -1824,7 +1824,7 @@
if
i32.const 0
i32.const 64
i32.const 593
i32.const 589
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/do.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@
if
i32.const 0
i32.const 64
i32.const 569
i32.const 565
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -3437,7 +3437,7 @@
if
i32.const 0
i32.const 64
i32.const 593
i32.const 589
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down
13 changes: 4 additions & 9 deletions tests/compiler/extends-baseaggregate.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@
if
i32.const 0
i32.const 128
i32.const 569
i32.const 565
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -1670,14 +1670,9 @@
i32.const 556
i32.ge_u
if
local.get $1
local.get $4
i32.const 1
i32.or
i32.store
local.get $0
local.get $1
call $~lib/rt/tlsf/insertBlock
call $~lib/rt/tlsf/freeBlock
end
local.get $3
)
Expand All @@ -1693,7 +1688,7 @@
if
i32.const 0
i32.const 128
i32.const 586
i32.const 582
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -2005,7 +2000,7 @@
if
i32.const 0
i32.const 128
i32.const 593
i32.const 589
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down
13 changes: 4 additions & 9 deletions tests/compiler/extends-baseaggregate.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@
if
i32.const 0
i32.const 128
i32.const 569
i32.const 565
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -3156,14 +3156,9 @@
global.get $~lib/heap/__heap_base
i32.ge_u
if
local.get $1
local.get $4
i32.const 1
i32.or
i32.store
local.get $0
local.get $1
call $~lib/rt/tlsf/insertBlock
call $~lib/rt/tlsf/freeBlock
end
local.get $8
)
Expand All @@ -3183,7 +3178,7 @@
if
i32.const 0
i32.const 128
i32.const 586
i32.const 582
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -3565,7 +3560,7 @@
if
i32.const 0
i32.const 128
i32.const 593
i32.const 589
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/for.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@
if
i32.const 0
i32.const 64
i32.const 569
i32.const 565
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -1844,7 +1844,7 @@
if
i32.const 0
i32.const 64
i32.const 593
i32.const 589
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/for.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,7 @@
if
i32.const 0
i32.const 64
i32.const 569
i32.const 565
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -3471,7 +3471,7 @@
if
i32.const 0
i32.const 64
i32.const 593
i32.const 589
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/managed-cast.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@
if
i32.const 0
i32.const 32
i32.const 569
i32.const 565
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -1588,7 +1588,7 @@
if
i32.const 0
i32.const 32
i32.const 593
i32.const 589
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/managed-cast.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@
if
i32.const 0
i32.const 32
i32.const 569
i32.const 565
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -3065,7 +3065,7 @@
if
i32.const 0
i32.const 32
i32.const 593
i32.const 589
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/rc/global-init.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@
if
i32.const 0
i32.const 96
i32.const 569
i32.const 565
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -3039,7 +3039,7 @@
if
i32.const 0
i32.const 96
i32.const 593
i32.const 589
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/rc/local-init.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@
if
i32.const 0
i32.const 96
i32.const 569
i32.const 565
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -1517,7 +1517,7 @@
if
i32.const 0
i32.const 96
i32.const 593
i32.const 589
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/rc/local-init.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@
if
i32.const 0
i32.const 96
i32.const 569
i32.const 565
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -2977,7 +2977,7 @@
if
i32.const 0
i32.const 96
i32.const 593
i32.const 589
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/rc/logical-and-mismatch.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@
if
i32.const 0
i32.const 32
i32.const 569
i32.const 565
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -1576,7 +1576,7 @@
if
i32.const 0
i32.const 32
i32.const 593
i32.const 589
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/rc/logical-and-mismatch.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@
if
i32.const 0
i32.const 32
i32.const 569
i32.const 565
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -3050,7 +3050,7 @@
if
i32.const 0
i32.const 32
i32.const 593
i32.const 589
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/rc/logical-or-mismatch.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@
if
i32.const 0
i32.const 32
i32.const 569
i32.const 565
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -1576,7 +1576,7 @@
if
i32.const 0
i32.const 32
i32.const 593
i32.const 589
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/rc/logical-or-mismatch.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@
if
i32.const 0
i32.const 32
i32.const 569
i32.const 565
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -3050,7 +3050,7 @@
if
i32.const 0
i32.const 32
i32.const 593
i32.const 589
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/rc/optimize.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@
if
i32.const 0
i32.const 80
i32.const 569
i32.const 565
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -1614,7 +1614,7 @@
if
i32.const 0
i32.const 80
i32.const 593
i32.const 589
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/rc/optimize.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@
if
i32.const 0
i32.const 80
i32.const 569
i32.const 565
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -3088,7 +3088,7 @@
if
i32.const 0
i32.const 80
i32.const 593
i32.const 589
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/rc/rereturn.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@
if
i32.const 0
i32.const 32
i32.const 569
i32.const 565
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down Expand Up @@ -1564,7 +1564,7 @@
if
i32.const 0
i32.const 32
i32.const 593
i32.const 589
i32.const 2
call $~lib/builtins/abort
unreachable
Expand Down
Loading