{"action":"created","issue":{"url":"https://api.github.com/repos/servo/heapsize/issues/9","labels_url":"https://api.github.com/repos/servo/heapsize/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/servo/heapsize/issues/9/comments","events_url":"https://api.github.com/repos/servo/heapsize/issues/9/events","html_url":"https://github.com/servo/heapsize/issues/9","id":99911315,"number":9,"title":"`heap_size_of` should be unsafe","user":{"login":"bluss","id":3209739,"avatar_url":"https://avatars.githubusercontent.com/u/3209739?v=3","gravatar_id":"","url":"https://api.github.com/users/bluss","html_url":"https://github.com/bluss","followers_url":"https://api.github.com/users/bluss/followers","following_url":"https://api.github.com/users/bluss/following{/other_user}","gists_url":"https://api.github.com/users/bluss/gists{/gist_id}","starred_url":"https://api.github.com/users/bluss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bluss/subscriptions","organizations_url":"https://api.github.com/users/bluss/orgs","repos_url":"https://api.github.com/users/bluss/repos","events_url":"https://api.github.com/users/bluss/events{/privacy}","received_events_url":"https://api.github.com/users/bluss/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-09T16:26:26Z","updated_at":"2015-08-10T08:44:42Z","closed_at":null,"body":"It draws attention directly by being marked safe but using a raw pointer argument.\r\n\r\nIt seems trivial to segfault using this function in safe rust, just give it a pointer to something not allocated, or a dangling pointer.\r\n\r\nTested using heapsize 0.1.0\r\n\r\n```rust\r\nheapsize::heap_size_of(2 as *const _);\r\n```"},"comment":{"url":"https://api.github.com/repos/servo/heapsize/issues/comments/129367876","html_url":"https://github.com/servo/heapsize/issues/9#issuecomment-129367876","issue_url":"https://api.github.com/repos/servo/heapsize/issues/9","id":129367876,"user":{"login":"bluss","id":3209739,"avatar_url":"https://avatars.githubusercontent.com/u/3209739?v=3","gravatar_id":"","url":"https://api.github.com/users/bluss","html_url":"https://github.com/bluss","followers_url":"https://api.github.com/users/bluss/followers","following_url":"https://api.github.com/users/bluss/following{/other_user}","gists_url":"https://api.github.com/users/bluss/gists{/gist_id}","starred_url":"https://api.github.com/users/bluss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bluss/subscriptions","organizations_url":"https://api.github.com/users/bluss/orgs","repos_url":"https://api.github.com/users/bluss/repos","events_url":"https://api.github.com/users/bluss/events{/privacy}","received_events_url":"https://api.github.com/users/bluss/received_events","type":"User","site_admin":false},"created_at":"2015-08-10T08:44:42Z","updated_at":"2015-08-10T08:44:42Z","body":"`let v = vec![0; N]; v[1..].as_ptr()` would have the same problem (pointer not from jemalloc).  Creating raw pointers being unsafe or not, the precondition is that the passed in pointer must have been returned from jemalloc, and that is not checkable by the type system."}}