{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/34227","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/34227/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/34227/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/34227/events","html_url":"https://github.com/rust-lang/rust/issues/34227","id":159783589,"number":34227,"title":"return_address intrinsic problematic with MIR and hard/impossible to use safely.","user":{"login":"eddyb","id":77424,"avatar_url":"https://avatars.githubusercontent.com/u/77424?v=3","gravatar_id":"","url":"https://api.github.com/users/eddyb","html_url":"https://github.com/eddyb","followers_url":"https://api.github.com/users/eddyb/followers","following_url":"https://api.github.com/users/eddyb/following{/other_user}","gists_url":"https://api.github.com/users/eddyb/gists{/gist_id}","starred_url":"https://api.github.com/users/eddyb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eddyb/subscriptions","organizations_url":"https://api.github.com/users/eddyb/orgs","repos_url":"https://api.github.com/users/eddyb/repos","events_url":"https://api.github.com/users/eddyb/events{/privacy}","received_events_url":"https://api.github.com/users/eddyb/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-mir","name":"A-mir","color":"d7e102"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-servo","name":"A-servo","color":"d7e102"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/I-nominated","name":"I-nominated","color":"e10c02"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/T-compiler","name":"T-compiler","color":"bfd4f2"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2016-06-11T17:21:13Z","updated_at":"2016-06-12T11:29:16Z","closed_at":null,"body":"Servo currently can't compile with `-Zorbit` (see servo/servo#11706) and my suspect is `return_address`.\r\n\r\nEven if that wasn't the reason, Servo's usage of `return_address` to create a rooting cycle only ever worked because it happened to get the final destination of the call, but with MIR, the call destination might be a temporary, so it's not the final destination anymore.\r\nServo has a lint for disallowing moves on the types that are being returned, but that analysis is wrong unless performed on *exactly* the MIR we translate.\r\n\r\nWe also could change the ABI at any time, so the indirect returns becomes direct (we can do this for any pair of pointer-sized values) which would also break Servo.\r\nI'm not even sure how LLVM doesn't miscompile what Servo is doing, capturing an `sret` argument seems quite dubious to me, and some architectures also have an intermediary copy.\r\n\r\nAFAIK, the eventual solution is to have proper stack map support, however that might be a long ways off and I don't want to block removing old trans on it.\r\n\r\ncc @jdm @pcwalton @Manishearth @rust-lang/compiler"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/225427549","html_url":"https://github.com/rust-lang/rust/issues/34227#issuecomment-225427549","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/34227","id":225427549,"user":{"login":"eddyb","id":77424,"avatar_url":"https://avatars.githubusercontent.com/u/77424?v=3","gravatar_id":"","url":"https://api.github.com/users/eddyb","html_url":"https://github.com/eddyb","followers_url":"https://api.github.com/users/eddyb/followers","following_url":"https://api.github.com/users/eddyb/following{/other_user}","gists_url":"https://api.github.com/users/eddyb/gists{/gist_id}","starred_url":"https://api.github.com/users/eddyb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eddyb/subscriptions","organizations_url":"https://api.github.com/users/eddyb/orgs","repos_url":"https://api.github.com/users/eddyb/repos","events_url":"https://api.github.com/users/eddyb/events{/privacy}","received_events_url":"https://api.github.com/users/eddyb/received_events","type":"User","site_admin":false},"created_at":"2016-06-12T11:29:16Z","updated_at":"2016-06-12T11:29:16Z","body":"In IRC @nox brought up that `Rooted` actually handles a moving GC, i.e. SM can update the pointer:\r\n```c\r\n/*\r\n * Moving GC Stack Rooting\r\n *\r\n * A moving GC may change the physical location of GC allocated things, even\r\n * when they are rooted, updating all pointers to the thing to refer to its new\r\n * location. The GC must therefore know about all live pointers to a thing,\r\n * not just one of them, in order to behave correctly.\r\n *\r\n * The classes below are used to root stack locations whose value may be held\r\n * live across a call that can trigger GC (i.e. a call which might allocate any\r\n * GC things). For a code fragment such as:\r\n *\r\n * Foo();\r\n * ... = obj->lastProperty();\r\n *\r\n * If Foo() can trigger a GC, the stack location of obj must be rooted to\r\n * ensure that the GC does not move the JSObject referred to by obj without\r\n * updating obj's location itself. This rooting must happen regardless of\r\n * whether there are other roots which ensure that the object itself will not\r\n * be collected.\r\n *\r\n * If Foo() cannot trigger a GC, and the same holds for all other calls made\r\n * between obj's definitions and its last uses, then no rooting is required.\r\n```\r\n\r\nThis does not invalidate my shadow stack suggestion, but it does require holding a reference to an element of the thread-local array (i.e. `&'static Cell<*mut JSObject>`).\r\nOTOH, you need a way to clear that slot (by writing NULL to it) anyway, so this is not worse."}}
{"actor":{"display_login":"eddyb"}}