{"action":"closed","issue":{"url":"https://api.github.com/repos/m8pple/arch2-2016-cw/issues/41","repository_url":"https://api.github.com/repos/m8pple/arch2-2016-cw","labels_url":"https://api.github.com/repos/m8pple/arch2-2016-cw/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/m8pple/arch2-2016-cw/issues/41/comments","events_url":"https://api.github.com/repos/m8pple/arch2-2016-cw/issues/41/events","html_url":"https://github.com/m8pple/arch2-2016-cw/issues/41","id":184717017,"number":41,"title":"Subtle bug in mem code","user":{"login":"ps-george","id":17267419,"avatar_url":"https://avatars.githubusercontent.com/u/17267419?v=3","gravatar_id":"","url":"https://api.github.com/users/ps-george","html_url":"https://github.com/ps-george","followers_url":"https://api.github.com/users/ps-george/followers","following_url":"https://api.github.com/users/ps-george/following{/other_user}","gists_url":"https://api.github.com/users/ps-george/gists{/gist_id}","starred_url":"https://api.github.com/users/ps-george/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ps-george/subscriptions","organizations_url":"https://api.github.com/users/ps-george/orgs","repos_url":"https://api.github.com/users/ps-george/repos","events_url":"https://api.github.com/users/ps-george/events{/privacy}","received_events_url":"https://api.github.com/users/ps-george/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-23T21:27:39Z","updated_at":"2016-10-26T16:21:00Z","closed_at":"2016-10-26T16:21:00Z","body":"Will the [subtle bug](https://github.com/m8pple/arch2-2016-cw/blob/master/src/shared/mips_mem_ram.cpp#L60) still be present in the code used for testing? \r\n\r\nWhen passing a negative address (or an extremely large positive address, but that is extremely unlikely) to mem_read, `address+length` may overflow, causing the condition `(address+length) > mem->length` to return false (and ultimately a segmentation fault (core dumped) on my program). This can be fixed by adding another condition: `address > (UINT32_MAX - length)`. It can also be prevented on the CPU side by building in a safeguard that prevents passing negative values to the memory handler.\r\n\r\nI can build a safeguard into my CPU, but others' CPUs may not have the same protection and **will** crash my test program when I test for mips_ExceptionInvalidAddress from a branch to a negative address. Shall I not test that condition or shall I assume the test code will not have the subtle bug?"}}
{"actor":{"display_login":"m8pple"}}