{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/27673","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/27673/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/27673/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/27673/events","html_url":"https://github.com/rust-lang/rust/issues/27673","id":100389794,"number":27673,"title":"Write::write_fmt causes page fault on a bare metal","user":{"login":"ababo","id":503292,"avatar_url":"https://avatars.githubusercontent.com/u/503292?v=3","gravatar_id":"","url":"https://api.github.com/users/ababo","html_url":"https://github.com/ababo","followers_url":"https://api.github.com/users/ababo/followers","following_url":"https://api.github.com/users/ababo/following{/other_user}","gists_url":"https://api.github.com/users/ababo/gists{/gist_id}","starred_url":"https://api.github.com/users/ababo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ababo/subscriptions","organizations_url":"https://api.github.com/users/ababo/orgs","repos_url":"https://api.github.com/users/ababo/repos","events_url":"https://api.github.com/users/ababo/events{/privacy}","received_events_url":"https://api.github.com/users/ababo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-11T19:32:45Z","updated_at":"2015-08-11T20:39:24Z","closed_at":null,"body":"My experimental code crashes when running on bare x86_64-metal (page fault when IDT is not yet set), but works perfectly on aarch64.\r\n\r\nBy careful tracing I figured out that the cause of this page fault consists of corrupted address (much higher than 0x200_000, while only the first 2M page is yet mapped as 1:1) of function \"f\" passed as an argument to core::fmt::ArgumentV1::new() function:\r\n\r\n```rust\r\n#[doc(hidden)]\r\n#[unstable(feature = \"fmt_internals\", reason = \"internal to format_args!\")]\r\npub fn new<'b, T>(x: &'b T,\r\n                  f: fn(&T, &mut Formatter) -> Result) -> ArgumentV1<'b> {\r\n    unsafe {\r\n        ArgumentV1 {\r\n            formatter: mem::transmute(f),\r\n            value: mem::transmute(x)\r\n        }\r\n    }\r\n} \r\n```\r\nAFAIK this value is hard-coded by rustc compiler being result of compile-time processing of format_args! variadic arguments."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/130060855","html_url":"https://github.com/rust-lang/rust/issues/27673#issuecomment-130060855","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/27673","id":130060855,"user":{"login":"ababo","id":503292,"avatar_url":"https://avatars.githubusercontent.com/u/503292?v=3","gravatar_id":"","url":"https://api.github.com/users/ababo","html_url":"https://github.com/ababo","followers_url":"https://api.github.com/users/ababo/followers","following_url":"https://api.github.com/users/ababo/following{/other_user}","gists_url":"https://api.github.com/users/ababo/gists{/gist_id}","starred_url":"https://api.github.com/users/ababo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ababo/subscriptions","organizations_url":"https://api.github.com/users/ababo/orgs","repos_url":"https://api.github.com/users/ababo/repos","events_url":"https://api.github.com/users/ababo/events{/privacy}","received_events_url":"https://api.github.com/users/ababo/received_events","type":"User","site_admin":false},"created_at":"2015-08-11T20:39:24Z","updated_at":"2015-08-11T20:39:24Z","body":"Take code from [here](https://github.com/ababo/arwen-tmp)."}}