RuntimeError: memory access out of bounds at js.__Porffor_strcat
Not sure if you want bug reports yet, given the project is still very much WIP, but the script I'm trying to run doesn't containing anything complex (no NodeJS stuff, no promises, etc). Just objects, arrays, strings, etc. Core stuff.
Anyway, I tried to give Porffor a go on this TypeScript project: https://github.com/KieranP/Game-Of-Life-Implementations/tree/master/typescript
It seems it doesn't quite like import/export yet (was getting `Error: todo: no generation for ImportDeclaration!`), so I joined the contents of world.js and play.js into a single file call porf.js and tried to run that, but am hitting this runtime memory access error:
```
$ porf -d porf.js
porffor backtrace
__Porffor_strcat(0) (a(0): i32, a#type(1): i32, b(2): i32, b#type(3): i32) -> (i32, i32)
local.get 0 ;; $a (i32)
i32.load 0 0
local.set 4 ;; $al (i32)
local.get 2 ;; $b (i32)
i32.load 0 0
local.set 5 ;; $bl (i32)
local.get 1 ;; $a#type (i32)
i32.const 195
i32.eq
if ;; label @1
local.get 3 ;; $b#type (i32)
i32.const 195
i32.eq
if ;; label @2
i32.const 4
local.get 4 ;; $al (i32)
i32.add
local.get 5 ;; $bl (i32)
i32.add
call 11 ;; $__Porffor_allocateBytes (i32) -> (i32)
local.tee 6 ;; $out (i32)
local.get 4 ;; $al (i32)
local.get 5 ;; $bl (i32)
i32.add
i32.store 0 0
local.get 6 ;; $out (i32)
i32.const 4
i32.add
local.get 0 ;; $a (i32)
i32.const 4
i32.add
local.get 4 ;; $al (i32)
memory.copy 0 0
local.get 6 ;; $out (i32)
i32.const 4
i32.add
local.get 4 ;; $al (i32)
i32.add
local.get 2 ;; $b (i32)
i32.const 4
i32.add
local.get 5 ;; $bl (i32)
memory.copy 0 0
local.get 6 ;; $out (i32)
i32.const 195
return
drop
else ;; label @2
i32.const 4
local.get 4 ;; $al (i32)
local.get 5 ;; $bl (i32)
i32.add
i32.const 2
i32.mul
i32.add
call 11 ;; $__Porffor_allocateBytes (i32) -> (i32)
local.tee 6 ;; $out (i32)
local.get 4 ;; $al (i32)
local.get 5 ;; $bl (i32)
i32.add
i32.store 0 0
i32.const 0
local.set 7 ;; $i (i32)
loop ;; label @3
local.get 7 ;; $i (i32)
local.get 4 ;; $al (i32)
i32.lt_s
if ;; label @4
local.get 6 ;; $out (i32)
local.get 7 ;; $i (i32)
i32.const 2
i32.mul
i32.add
local.get 0 ;; $a (i32)
local.get 7 ;; $i (i32)
i32.add
i32.load8_u 0 4
i32.store16 0 4
local.get 7 ;; $i (i32)
i32.const 1
i32.add
local.set 7 ;; $i (i32)
br 1 ;; goto @3
end
end
local.get 6 ;; $out (i32)
i32.const 4
i32.add
local.get 4 ;; $al (i32)
i32.const 2
i32.mul
i32.add
local.get 2 ;; $b (i32)
i32.const 4
i32.add
local.get 5 ;; $bl (i32)
i32.const 2
i32.mul
memory.copy 0 0
local.get 6 ;; $out (i32)
i32.const 67
return
drop
end
else ;; label @1
local.get 3 ;; $b#type (i32)
i32.const 195
i32.eq
if ;; label @2
i32.const 4
local.get 4 ;; $al (i32)
local.get 5 ;; $bl (i32)
i32.add
i32.const 2
i32.mul
i32.add
call 11 ;; $__Porffor_allocateBytes (i32) -> (i32)
local.tee 6 ;; $out (i32)
local.get 4 ;; $al (i32)
local.get 5 ;; $bl (i32)
i32.add
i32.store 0 0
local.get 6 ;; $out (i32)
i32.const 4
i32.add
local.get 0 ;; $a (i32)
i32.const 4
i32.add
local.get 4 ;; $al (i32)
i32.const 2
i32.mul
memory.copy 0 0
local.get 6 ;; $out (i32)
local.get 4 ;; $al (i32)
i32.const 2
i32.mul
i32.add
local.set 8 ;; $ptr (i32)
i32.const 0
local.set 7 ;; $i (i32)
loop ;; label @3
local.get 7 ;; $i (i32)
local.get 5 ;; $bl (i32)
i32.lt_s
if ;; label @4
local.get 8 ;; $ptr (i32)
local.get 7 ;; $i (i32)
i32.const 2
i32.mul
i32.add
local.get 2 ;; $b (i32)
local.get 7 ;; $i (i32)
i32.add
i32.load8_u 0 4
i32.store16 0 4
local.get 7 ;; $i (i32)
i32.const 1
i32.add
local.set 7 ;; $i (i32)
br 1 ;; goto @3
end
end
local.get 6 ;; $out (i32)
i32.const 67
return
drop
else ;; label @2
i32.const 4
local.get 4 ;; $al (i32)
local.get 5 ;; $bl (i32)
i32.add
i32.const 2
i32.mul
i32.add
call 11 ;; $__Porffor_allocateBytes (i32) -> (i32)
local.tee 6 ;; $out (i32)
local.get 4 ;; $al (i32)
local.get 5 ;; $bl (i32)
i32.add
i32.store 0 0
local.get 6 ;; $out (i32)
i32.const 4
i32.add
local.get 0 ;; $a (i32)
i32.const 4
i32.add
local.get 4 ;; $al (i32)
i32.const 2
i32.mul
memory.copy 0 0
local.get 6 ;; $out (i32)
i32.const 4
i32.add
local.get 4 ;; $al (i32)
i32.const 2
i32.mul
i32.add
local.get 2 ;; $b (i32)
i32.const 4
i32.add
local.get 5 ;; $bl (i32)
i32.const 2
i32.mul
memory.copy 0 0
local.get 6 ;; $out (i32)
i32.const 67
return
drop
end
end
i32.const 0
i32.const 0
return
RuntimeError: memory access out of bounds
at js.__Porffor_strcat (wasm://wasm/js-0005c3c2:wasm-function[85]:0x5acf)
at js.__Porffor_concatStrings (wasm://wasm/js-0005c3c2:wasm-function[5]:0xc17)
at js.__#cell_at (wasm://wasm/js-0005c3c2:wasm-function[109]:0x8718)
at js.#indirect___#cell_at (wasm://wasm/js-0005c3c2:wasm-function[158]:0xd6ad)
at js.__#prepopulate_neighbours (wasm://wasm/js-0005c3c2:wasm-function[116]:0x9a9e)
at js.#indirect___#prepopulate_neighbours (wasm://wasm/js-0005c3c2:wasm-function[161]:0xd761)
at js.World (wasm://wasm/js-0005c3c2:wasm-function[97]:0x6401)
at js.run (wasm://wasm/js-0005c3c2:wasm-function[122]:0xa5f2)
at js.#indirect_run (wasm://wasm/js-0005c3c2:wasm-function[166]:0xd833)
at js.#main (wasm://wasm/js-0005c3c2:wasm-function[3]:0xa1b)
```
The function in question (#cell_at) looks like this: (takes two integers, e.g. 2 and 12, and returns a string, e.g. "2-12")
```
#cell_at(x, y) {
return this.#cells.get(`${x}-${y}`);
}
```
0 条评论