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
bat -p Segfaults on macOS Catalina #680
Comments
Thank you very much for reporting this. From the backtrace, it looks like this happens within the oniguruma library (written in C). To verify this, you could try to run Are you sure that this happens for each and every input? What about something really simple like the following? echo test | bat or echo '<test arg="1"></test>' | bat -l xml |
The above all segfault, I'm not sure how to completely disable syntax highlighting however. Would
|
No, but I would have assumed that echo hi | bat | cat should work (assuming In any case, I don't think there is much we can do here (except maybe roll back our dependencies). We need to report this upstream (in If possible, it would be great if you could clone https://github.com/trishume/syntect and run
on a simple file. |
Not sure if it's regarding the same problem, but just updated to Catalina and |
I did a little research and found that there are a few reports about programs suddenly segfaulting with This
Maybe there are some low-level operations in Could one of you please try to run some example programs from git clone https://github.com/kkos/oniguruma
mkdir oniguruma/sample/build
cd oniguruma/sample/build
cmake ..
make
# run examples like:
./count |
There are also some interesting things going on with bitwidths in the I would look into it myself, but I don't have a macOS machine or a Catalina image which I could run in a VM. |
The samples work on Catalina for all the version I've tried of oniguruma (master, 6.9.3(latest), 83572e983928243d741f61ac290fc057d69fefc3). While I can't add much on the cause behind the crash, a thing I've noticed is that the latest version of rust-onig (v5.0.0) still points to oniguruma:83572e983928243d741f61ac290fc057d69fefc3 from April 23rd, way older than the latest release 6.9.3 tagged in August (and that contains fixes for two CVEs and a lot of fixes found by a fuzzer). |
Ok, so I:
The issue remains. |
On the other hand, updating the ➜ bin/bat -p test.rb
#! /bin/usr/env ruby
class HelloWorld
def run!
puts "Hello world!"
end
end
HelloWorld.new.run! |
This upgrades the oniguruma submodule to fix issues some libraries that depend on rust-onig are experiencing in macOS 10.15. For examples and more context, see: sharkdp/bat#680 dandavison/delta#24
BTW,
|
|
According to this post, % bat --version
bat 0.12.1
% otool -xvV /usr/local/bin/bat | grep "^_match_at:$" -A512
...
00000001000d65b3 callq 0x1002a0402 ## symbol stub for: ____chkstk_darwin
...
00000001000d6852 jmpq *(%r10)
... I ran bat on LLDB, and found that the value of I believe bat works fine if we can elminate calls to |
@mkYYY That's an interesting finding. The code responsible for building oniguruma is here in the onig_sys crate. I believe it would be possible to add an option to disable I would recommend opening an issue with your findings there as well, since they apply to the onig crate and can be used to provide a workaround for other projects that use it. @mkYYY @sharkdp Would a temporary solution As a side note, I'm curious why |
@eth-p Thanks for the reply. I'm going to open it soon. |
@jan-auer Could you share how to install
|
Never mind, downloaded https://github.com/sharkdp/bat/releases/download/v0.11.0/bat-v0.11.0-x86_64-apple-darwin.tar.gz and replaced `/usr/local/bin/bat` with it
…On Nov 10, 2019, 5:39 PM +0800, Birkhoff Lee ***@***.***>, wrote:
@jan-auer Could you share how to install 0.11.0_1 via homebrew? I've tried the followings without luck :(
$ brew install ***@***.***_1
$ brew install ***@***.***
$ brew install ***@***.***
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
FWIW, uninstalling the bat bottle and reinstalling from source (0.12.1) seems to have cleared up the segfault problem for me on MacOS Catalina (10.15.1).
|
@joevo Good to know that works. I suppose that means it's fixed upstream? |
Just tried it and it’s still segfault’ing on my side.
…On Nov 11, 2019, 9:25 AM +0800, Ethan P. ***@***.***>, wrote:
@joevo Good to know that works. I suppose that means it's fixed upstream?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
One thing I need to correct is that this odd behaviour is not because of $ /usr/local/opt/bat/bin/bat --version
bat 0.12.1
$ xxd /usr/lib/dyld | head -n 5 | /usr/local/opt/bat/bin/bat
Segmentation fault: 11
$ export DYLD_BIND_AT_LAUNCH=1
$ xxd /usr/lib/dyld | head -n 5 | /usr/local/opt/bat/bin/bat
───────┬─────────────────────────────────────────────────────────────────────────────
│ STDIN
───────┼─────────────────────────────────────────────────────────────────────────────
1 │ 00000000: cafe babe 0000 0002 0100 0007 0000 0003 ................
2 │ 00000010: 0000 1000 000c e4e0 0000 000c 0000 0007 ................
3 │ 00000020: 0000 0003 000d 0000 000a c7a0 0000 000c ................
4 │ 00000030: 0000 0000 0000 0000 0000 0000 0000 0000 ................
5 │ 00000040: 0000 0000 0000 0000 0000 0000 0000 0000 ................
───────┴─────────────────────────────────────────────────────────────────────────────
$ unset DYLD_BIND_AT_LAUNCH
$ xxd /usr/lib/dyld | head -n 5 | /usr/local/opt/bat/bin/bat
Segmentation fault: 11 Unfortunately, if the root cause is in |
I added the following to the brew recipe: ENV.append "RUSTFLAGS", "-Clink-args=-Wl,-bind_at_load" Appears to be what was needed. |
@archite Great! Did you PR or opened an issue on brew? |
I added #46770 to Homebrew/homebrew-core. |
Hi, Homebrew maintainer here. We've had a lot of trouble with Xcode 11's default stack-check, and the root issue is that Xcode 11's clang produces invalid code with this option. Apple is aware and should fix it, but the fix didn't make it in Xcode 11.2.
|
This fixed the issue for me, and as a side bonus I now have rust installed |
I've updated the PR. This works well and appears to be more standard across home-brew core.
|
Same here, but then I updated Xcode to 11.2.1 and now reinstalling from source works. |
Is there anything left to be done within the Edit: probably can not be closed, as I would expect this to still fail when someone is using |
@sharkdp Homebrew has been updated so it can be closed. |
Had to reinstall |
Maybe this will be sufficient; these env vars should get picked up by the `cc` crate. Fingers crossed! refs: #128 refs: sharkdp/bat#680
I get the same segfault when installed via Homebrew as well as
cargo install bat
Steps to reproduce:
The text was updated successfully, but these errors were encountered: