{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/50586","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/50586/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/50586/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/50586/events","html_url":"https://github.com/rust-lang/rust/issues/50586","id":321736098,"number":50586,"title":"[MacOS] nightly causes runtime segfault when crate binary is compiled with --release","user":{"login":"jjpe","id":1242003,"avatar_url":"https://avatars3.githubusercontent.com/u/1242003?v=4","gravatar_id":"","url":"https://api.github.com/users/jjpe","html_url":"https://github.com/jjpe","followers_url":"https://api.github.com/users/jjpe/followers","following_url":"https://api.github.com/users/jjpe/following{/other_user}","gists_url":"https://api.github.com/users/jjpe/gists{/gist_id}","starred_url":"https://api.github.com/users/jjpe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjpe/subscriptions","organizations_url":"https://api.github.com/users/jjpe/orgs","repos_url":"https://api.github.com/users/jjpe/repos","events_url":"https://api.github.com/users/jjpe/events{/privacy}","received_events_url":"https://api.github.com/users/jjpe/received_events","type":"User","site_admin":false},"labels":[{"id":650731663,"url":"https://api.github.com/repos/rust-lang/rust/labels/C-bug","name":"C-bug","color":"f5f1fd","default":false},{"id":123111,"url":"https://api.github.com/repos/rust-lang/rust/labels/O-macos","name":"O-macos","color":"6e6ec0","default":false},{"id":203429200,"url":"https://api.github.com/repos/rust-lang/rust/labels/P-high","name":"P-high","color":"eb6420","default":false},{"id":262252840,"url":"https://api.github.com/repos/rust-lang/rust/labels/regression-from-stable-to-stable","name":"regression-from-stable-to-stable","color":"e4008a","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2018-05-09T21:40:25Z","updated_at":"2018-05-15T09:07:42Z","closed_at":null,"author_association":"NONE","body":"On OS X 10.10, when I compile a crate I wrote for work and run the crate binary using `cargo run --release`, the generated binary will segfault when I try certain actions. Oddly enough, debug builds do not seem to exhibit the segfaulting behavior at all.\r\n\r\nThis bug is tricky to describe, as I have no clue what causes the generated binary to segfault.\r\nJust to rule out the factor: the crate I'm building has no `unsafe` code.  \r\nHowever, I do know that compiling using up to and including `rustc 1.26.0-nightly (392645394 2018-03-15)`, the generated crate binary runs fine.\r\n\r\nStarting with `rustc 1.26.0-nightly (55c984ee5 2018-03-16)` something has changed in behavior to cause this segfault on OS X.\r\n\r\nFor context and some additional information, please see the discussion on [users.rust-lang.org](https://users.rust-lang.org/t/no-issues-on-linux-segfault-on-os-x-but-only-when-building-with-release)."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/389097749","html_url":"https://github.com/rust-lang/rust/issues/50586#issuecomment-389097749","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/50586","id":389097749,"user":{"login":"jjpe","id":1242003,"avatar_url":"https://avatars3.githubusercontent.com/u/1242003?v=4","gravatar_id":"","url":"https://api.github.com/users/jjpe","html_url":"https://github.com/jjpe","followers_url":"https://api.github.com/users/jjpe/followers","following_url":"https://api.github.com/users/jjpe/following{/other_user}","gists_url":"https://api.github.com/users/jjpe/gists{/gist_id}","starred_url":"https://api.github.com/users/jjpe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjpe/subscriptions","organizations_url":"https://api.github.com/users/jjpe/orgs","repos_url":"https://api.github.com/users/jjpe/repos","events_url":"https://api.github.com/users/jjpe/events{/privacy}","received_events_url":"https://api.github.com/users/jjpe/received_events","type":"User","site_admin":false},"created_at":"2018-05-15T09:07:42Z","updated_at":"2018-05-15T09:07:42Z","author_association":"NONE","body":"I tried turning on `LTO`, and that definitely makes the segfault go away on OS X.\r\nIn addition, I built the code with `--release` in Linux and Win10, and there are no regressions there that I can detect ATM.\r\n\r\nAs for where the issue occurs, the code sample I mentioned on [rust-lang.org](https://users.rust-lang.org/t/no-issues-on-linux-segfault-on-os-x-but-only-when-building-with-release) is this:\r\n```` rust\r\n    pub fn read_regex(&mut self, regex: &Regex) -> LexResult<Token> {\r\n        self.ensure_has_input()?;\r\n        let (m_start, m_end) = match regex.find(self.remaining_source_code()) {\r\n            Some(regex_match) if regex_match.start() == 0 =>\r\n                (regex_match.start(),  regex_match.end()),\r\n            _ => return Err(LexErr::ExpectedRegexMatch {\r\n                position: self.position()\r\n            }),\r\n        };\r\n        let start = self.position() + m_start;\r\n        let end   = self.position() + m_end;\r\n        self.position = end;\r\n        Ok(Token::new(start..end))\r\n    }\r\n````\r\n\r\nThe segfault location here is in the `regex.find(self.remaining_source_code())` method call (as opposed to its argument `self.remaining_source_code()`, which works as it should).  So it doesn't *only* happen in `Regex.captures()`.\r\n"}}
{"actor":{"display_login":"jjpe"}}