{"action":"created","issue":{"url":"https://api.github.com/repos/AssemblyScript/assemblyscript/issues/175","repository_url":"https://api.github.com/repos/AssemblyScript/assemblyscript","labels_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/issues/175/labels{/name}","comments_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/issues/175/comments","events_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/issues/175/events","html_url":"https://github.com/AssemblyScript/assemblyscript/issues/175","id":342266468,"node_id":"MDU6SXNzdWUzNDIyNjY0Njg=","number":175,"title":"RuntimeError: memory access out of bounds","user":{"login":"feedthejim","id":11064311,"node_id":"MDQ6VXNlcjExMDY0MzEx","avatar_url":"https://avatars3.githubusercontent.com/u/11064311?v=4","gravatar_id":"","url":"https://api.github.com/users/feedthejim","html_url":"https://github.com/feedthejim","followers_url":"https://api.github.com/users/feedthejim/followers","following_url":"https://api.github.com/users/feedthejim/following{/other_user}","gists_url":"https://api.github.com/users/feedthejim/gists{/gist_id}","starred_url":"https://api.github.com/users/feedthejim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/feedthejim/subscriptions","organizations_url":"https://api.github.com/users/feedthejim/orgs","repos_url":"https://api.github.com/users/feedthejim/repos","events_url":"https://api.github.com/users/feedthejim/events{/privacy}","received_events_url":"https://api.github.com/users/feedthejim/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-07-18T10:19:26Z","updated_at":"2018-07-18T13:11:37Z","closed_at":null,"author_association":"NONE","body":"hi, it's me again. I'm getting the following error without any ways of debugging (for some reason, Mozilla does't execute my code.\r\n\r\n```\r\nUncaught (in promise) RuntimeError: memory access out of bounds\r\n    at assembly/Vector3/Vector3#subtract (wasm-function[24]:5)\r\n    at assembly/Sphere/Sphere#intersect (wasm-function[26]:12)\r\n    at assembly/RayTracer/RayTracer#trace (wasm-function[32]:56)\r\n    at assembly/RayTracer/RayTracer#render (wasm-function[33]:309)\r\n    at assembly/index/init (wasm-function[34]:970)\r\n    at WebAssembly.instantiateStreaming.then.module \r\n``` \r\nHere are the relevants bits of code.\r\n\r\n`Vector3.ts`\r\n\r\n```\r\n  subtract(v2: Vector3): Vector3 {\r\n    return new Vector3(this.x - v2.x, this.y - v2.y, this.z - v2.z);\r\n  }\r\n```\r\n\r\n`Sphere.ts`\r\n\r\n```\r\n  intersect(rayOrigin: Vector3, rayDirection: Vector3): Intersection | null {\r\n    let l: Vector3 = this.center.subtract(rayOrigin);\r\n  \r\n```\r\n\r\n`RayTracer.ts`\r\n\r\n```\r\n     let transmission: Vector3 = new Vector3(1, 1, 1);\r\n        let lightDirection = this.elements[i].center\r\n          .subtract(intersectionPoint)\r\n          .normalize();\r\n        for (let j = 0; j < this.elements.length; j++) {\r\n          if (i !== j) {\r\n            let hitInfo: Intersection | null = this.elements[j].intersect(\r\n              intersectionPoint.add(intersectionNormal.multiply(bias)),\r\n              lightDirection,\r\n            );\r\n           \r\n```\r\nAny idea how I could debug my own code ? What are the best practices when using the arena allocator etc ? I haven't seen any example of using dynamic allocation on any of the projects using assemblyscript.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/AssemblyScript/assemblyscript/issues/comments/405925049","html_url":"https://github.com/AssemblyScript/assemblyscript/issues/175#issuecomment-405925049","issue_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/issues/175","id":405925049,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNTkyNTA0OQ==","user":{"login":"MaxGraey","id":1301959,"node_id":"MDQ6VXNlcjEzMDE5NTk=","avatar_url":"https://avatars3.githubusercontent.com/u/1301959?v=4","gravatar_id":"","url":"https://api.github.com/users/MaxGraey","html_url":"https://github.com/MaxGraey","followers_url":"https://api.github.com/users/MaxGraey/followers","following_url":"https://api.github.com/users/MaxGraey/following{/other_user}","gists_url":"https://api.github.com/users/MaxGraey/gists{/gist_id}","starred_url":"https://api.github.com/users/MaxGraey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaxGraey/subscriptions","organizations_url":"https://api.github.com/users/MaxGraey/orgs","repos_url":"https://api.github.com/users/MaxGraey/repos","events_url":"https://api.github.com/users/MaxGraey/events{/privacy}","received_events_url":"https://api.github.com/users/MaxGraey/received_events","type":"User","site_admin":false},"created_at":"2018-07-18T13:11:37Z","updated_at":"2018-07-18T13:11:37Z","author_association":"CONTRIBUTOR","body":"I finish prepare your example and don't see any exceptions:\r\nUpdate version: https://webassembly.studio/?f=gp6rm11tr5o"}}
{"actor":{"display_login":"MaxGraey"}}