Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fish segfaults on launch (parsing builtin config.fish) when built from HEAD with homebrew #4678

Closed
thomcc opened this issue Jan 22, 2018 · 3 comments
Labels
bug Something that's not working as intended
Milestone

Comments

@thomcc
Copy link
Contributor

thomcc commented Jan 22, 2018

I've updated my local install of fish using homebrew to 020fe5c, and it segfaults at launch, while reading config.fish.

Here's what I see when running it in lldb and when running it with a high --debug-level: https://gist.github.com/thomcc/4bda5472facccd4c93884df3e3e50044 (actually, it now includes function disassemblies too).

From the disassemblies, it looks like the compiler is dropping the test for child here: https://github.com/fish-shell/fish-shell/blob/master/src/tnode.h#L147, since it's assuming a that a reference can never be nullptr, since that's UB (note that it rewrites the function a bit so that it skips to the end when nodeptr is nullptr, so it knows child couldn't be null for that reason).

There could be other issues as well, of course, especially if other code has the same problem (e.g. assumes a reference could be nullptr).

Unfortunately, this sort of issue is very tricky to repro, and I can't actually get it to happen on a build outside of installing from homebrew, even though everything else should be the same (I guess it's possible that it has a different path and is finding a different clang? I don't know).

It's reliable for me inside homebrew, though.

@zanchey zanchey added the bug Something that's not working as intended label Jan 23, 2018
@zanchey zanchey added this to the fish-3.0 milestone Jan 23, 2018
@zanchey
Copy link
Member

zanchey commented Jan 23, 2018

Yes, I can reproduce this with Homebrew builds on macOS 10.11 as well. Interestingly it's something to do with the environment in the Homebrew build stage, as configuring the tree outside Homebrew then running make inside brew sh produces a segfault.

thomcc pushed a commit to thomcc/fish-shell that referenced this issue Jan 23, 2018
…-shell#4678.

- Change `try_get_child` to use `tree->get_child` instead of `get_child_node`.
- Asserts that `get_child_node` cannot return a reference to nullptr.
@zanchey
Copy link
Member

zanchey commented Jan 24, 2018

Oh, wow - Homebrew silently rewrites the flags passed to the compiler, so that's awesome. That's why you can't get debug symbols even though -g appears to be in CXXFLAGS.

I can reproduce this on macOS and Linux with ./configure CXX=clang++ CXXFLAGS="-g -Os".

@ridiculousfish
Copy link
Member

Nice analysis! Should be fixed by 5b37298. Thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something that's not working as intended
Projects
None yet
Development

No branches or pull requests

3 participants