{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/10389","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/10389/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/10389/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/10389/events","html_url":"https://github.com/rust-lang/rust/issues/10389","id":22395131,"node_id":"MDU6SXNzdWUyMjM5NTEzMQ==","number":10389,"title":"Collisions in type_id","user":{"login":"DaGenix","id":2101211,"node_id":"MDQ6VXNlcjIxMDEyMTE=","avatar_url":"https://avatars2.githubusercontent.com/u/2101211?v=4","gravatar_id":"","url":"https://api.github.com/users/DaGenix","html_url":"https://github.com/DaGenix","followers_url":"https://api.github.com/users/DaGenix/followers","following_url":"https://api.github.com/users/DaGenix/following{/other_user}","gists_url":"https://api.github.com/users/DaGenix/gists{/gist_id}","starred_url":"https://api.github.com/users/DaGenix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaGenix/subscriptions","organizations_url":"https://api.github.com/users/DaGenix/orgs","repos_url":"https://api.github.com/users/DaGenix/repos","events_url":"https://api.github.com/users/DaGenix/events{/privacy}","received_events_url":"https://api.github.com/users/DaGenix/received_events","type":"User","site_admin":false},"labels":[{"id":650731663,"node_id":"MDU6TGFiZWw2NTA3MzE2NjM=","url":"https://api.github.com/repos/rust-lang/rust/labels/C-bug","name":"C-bug","color":"f5f1fd","default":false},{"id":267612997,"node_id":"MDU6TGFiZWwyNjc2MTI5OTc=","url":"https://api.github.com/repos/rust-lang/rust/labels/I-unsound%20%F0%9F%92%A5","name":"I-unsound 💥","color":"e11d21","default":false},{"id":60329014,"node_id":"MDU6TGFiZWw2MDMyOTAxNA==","url":"https://api.github.com/repos/rust-lang/rust/labels/P-low","name":"P-low","color":"eb6420","default":false},{"id":211668019,"node_id":"MDU6TGFiZWwyMTE2NjgwMTk=","url":"https://api.github.com/repos/rust-lang/rust/labels/T-lang","name":"T-lang","color":"bfd4f2","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":30,"created_at":"2013-11-09T22:29:16Z","updated_at":"2018-11-08T17:18:58Z","closed_at":null,"author_association":"NONE","body":"The implementation of type_id from #10182 uses SipHash on various parameters depending on the type. The output size of SipHash is only 64-bits, however, making it feasible to find collisions via a Birthday Attack. I believe the code below demonstrates a collision in the type_id value of two different ty_structs:\n\n``` rust\nuse std::hash;\nuse std::hash::Streaming;\n\n// I believe that this pretty much the same thing as hash_crate_independent() in ty.rs\n// for a ty_struct on a 64-bit platform\nfn hash_struct(local_hash: &str, node: u64) -> u64 {\n    let mut state = hash::default_state();\n    state.input([18]);\n    state.input(local_hash.as_bytes());\n    do node.iter_bytes(true) |bytes| { state.input(bytes); true };\n    state.result_u64()\n}\n\nfn main() {\n    // This represents two structures with different node values from a crate with a \n    // local_hash value of \"local\" that end up getting the same hash and thus, \n    // I think, the same type_id\n    assert!(hash_struct(\"local\", 0x9e02c8943c336302) == hash_struct(\"local\", 0x366a806b1d5f1b2));\n}\n```\n"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/437083456","html_url":"https://github.com/rust-lang/rust/issues/10389#issuecomment-437083456","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/10389","id":437083456,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNzA4MzQ1Ng==","user":{"login":"ubsan","id":3479021,"node_id":"MDQ6VXNlcjM0NzkwMjE=","avatar_url":"https://avatars1.githubusercontent.com/u/3479021?v=4","gravatar_id":"","url":"https://api.github.com/users/ubsan","html_url":"https://github.com/ubsan","followers_url":"https://api.github.com/users/ubsan/followers","following_url":"https://api.github.com/users/ubsan/following{/other_user}","gists_url":"https://api.github.com/users/ubsan/gists{/gist_id}","starred_url":"https://api.github.com/users/ubsan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubsan/subscriptions","organizations_url":"https://api.github.com/users/ubsan/orgs","repos_url":"https://api.github.com/users/ubsan/repos","events_url":"https://api.github.com/users/ubsan/events{/privacy}","received_events_url":"https://api.github.com/users/ubsan/received_events","type":"User","site_admin":false},"created_at":"2018-11-08T17:18:58Z","updated_at":"2018-11-08T17:18:58Z","author_association":"CONTRIBUTOR","body":"@rkruppe huh! then I guess whatever information we pass to the hash function :P"}}
{"actor":{"display_login":"ubsan"}}