bat: bat -p Segfaults on macOS Catalina

I get the same segfault when installed via Homebrew as well as cargo install bat

 > uname -a
Darwin Armstrong.localdomain 19.0.0 Darwin Kernel Version 19.0.0: Wed Sep 25 20:18:50 PDT 2019; root:xnu-6153.11.26~2/RELEASE_X86_64 x86_64

 > bat --version
bat 0.12.1

Steps to reproduce:

bat -p # with any input
Process:               bat [4763]
Path:                  /Users/USER/*/bat
Identifier:            bat
Version:               0
Code Type:             X86-64 (Native)
Parent Process:        fish [713]
Responsible:           alacritty [711]
User ID:               501

Date/Time:             2019-10-08 11:24:34.261 -0700
OS Version:            Mac OS X 10.15 (19A583)
Report Version:        12
Bridge OS Version:     4.0 (17P572)
Anonymous UUID:        6CC6A47B-39EF-88AF-67D4-0C1D3FCFDFF0


Time Awake Since Boot: 730 seconds

System Integrity Protection: disabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       EXC_I386_GPFLT
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [4763]

Application Specific Information:
dyld2 mode

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   bat                           	0x00000001017970c2 match_at + 1250
1   bat                           	0x000000010179d360 onig_search_with_param + 2160
2   bat                           	0x000000010176d6b1 onig::Regex::search_with_param::h4a2ba9521397b8df + 145
3   bat                           	0x000000010174cf93 syntect::parsing::parser::ParseState::parse_line::ha082d257fdc53148 + 3411
4   bat                           	0x0000000101759f0a syntect::easy::HighlightLines::highlight::hc4ee6d0038f87c5c + 42
5   bat                           	0x000000010170ce3b _$LT$bat..printer..InteractivePrinter$u20$as$u20$bat..printer..Printer$GT$::print_line::hf1d17cfd22dd316e + 971
6   bat                           	0x00000001016fc43a bat::controller::Controller::run::h6430c3ee59245cfc + 2618
7   bat                           	0x0000000101711e6f bat::main::h5ed4543155eda5e6 + 8207
8   bat                           	0x00000001016e2fe6 std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h18bdc78d30f51494 + 6
9   bat                           	0x0000000101938a78 std::panicking::try::do_call::h8ffcb2a43dbb732c + 24
10  bat                           	0x000000010193f6bf __rust_maybe_catch_panic + 31
11  bat                           	0x00000001019393ee std::rt::lang_start_internal::ha688fd553625ef6f + 542
12  bat                           	0x0000000101712b79 main + 41
13  libdyld.dylib                 	0x00007fff72d5c405 start + 1

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x0000000000000010  rcx: 0x0000000101adb570  rdx: 0x00007ffeee52f900
  rdi: 0x00007fc704e9ae20  rsi: 0x0000000000000000  rbp: 0x00007ffeee530fb0  rsp: 0x00007ffeee52f900
   r8: 0x00007fc704e9ad30   r9: 0x0000000000000000  r10: 0x00007ffeee532a28  r11: 0x00007ffeee52f900
  r12: 0x00007fc704e9ad30  r13: 0x00007fc704e9ad3a  r14: 0x0000000000000000  r15: 0x00007fc704e9ae20
  rip: 0x00000001017970c2  rfl: 0x0000000000010246  cr2: 0x0000000101be3f48
  
Logical CPU:     0
Error Code:      0x00000000
Trap Number:     13


Binary Images:
       0x1016cd000 -        0x101ab0fe7 +bat (0) <CE78E092-983D-3861-ACD0-6AD4D8947D34> /Users/USER/*/bat
       0x1025b3000 -        0x10264193f  dyld (732.8) <42C11B81-6928-369F-B03E-D57355572700> /usr/lib/dyld
    0x7fff379a2000 -     0x7fff379a2fff  com.apple.Accelerate (1.11 - Accelerate 1.11) <956D070C-B522-3A08-891A-CAD6BA4082D1> /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
    0x7fff379ba000 -     0x7fff38025fdf  com.apple.vImage (8.1 - 524.2) <45A48EA9-49AA-33A0-B830-AF754BD01009> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage
    0x7fff38026000 -     0x7fff3828efff  libBLAS.dylib (1303) <112B19CC-925A-3E28-8B32-2002D30A37FA> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
    0x7fff3828f000 -     0x7fff3857efdf  libBNNS.dylib (144.11.2) <A806AED9-837B-3C6C-AB0B-A41983C1CD07> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBNNS.dylib
    0x7fff38580000 -     0x7fff38925fff  libLAPACK.dylib (1303) <5C248B39-F233-3074-A3A5-AF8F436FBF87> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
    0x7fff38926000 -     0x7fff3893bff8  libLinearAlgebra.dylib (1303) <C21931B4-F6BD-324D-A2D9-F13EE8AFB29E> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLinearAlgebra.dylib
    0x7fff3893c000 -     0x7fff38941ff3  libQuadrature.dylib (7) <826897ED-B7AD-33DC-B9CB-F9787784F312> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libQuadrature.dylib
    0x7fff38942000 -     0x7fff389b2fff  libSparse.dylib (103) <55467C29-2096-36AB-8A6D-5231A342809D> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libSparse.dylib
    0x7fff389b3000 -     0x7fff389c5fef  libSparseBLAS.dylib (1303) <3244FCAF-A1FE-3248-AF22-BFB3E9D12555> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libSparseBLAS.dylib
    0x7fff389c6000 -     0x7fff38b9fffb  libvDSP.dylib (735) <E849AEB0-2995-38A4-B0C3-4ACEAF434D12> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib
    0x7fff38ba0000 -     0x7fff38c5bfd3  libvMisc.dylib (735) <D6248EC4-7772-37BB-87F7-9BAB7F5D31A0> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib
    0x7fff38c5c000 -     0x7fff38c5cfff  com.apple.Accelerate.vecLib (3.11 - vecLib 3.11) <79C1A1C7-E97A-3B7A-8737-444B402A7AA0> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib
    0x7fff3a387000 -     0x7fff3a6fdffe  com.apple.CFNetwork (1111 - 1111) <642753C5-5D26-3794-9A4C-4F63F226C01A> /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
    0x7fff3bbbc000 -     0x7fff3c03bff7  com.apple.CoreFoundation (6.9 - 1671.15) <BF8A8279-9C5E-37C6-8426-90C8182EFBDD> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
    0x7fff3cfa3000 -     0x7fff3cfa3fff  com.apple.CoreServices (1069.2 - 1069.2) <C5F7AABC-BADC-3331-A7D6-9B0A82A23E58> /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
    0x7fff3cfa4000 -     0x7fff3d029ff7  com.apple.AE (838 - 838) <7295ED82-7087-3602-9DCA-4FE205F6499C> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
    0x7fff3d02a000 -     0x7fff3d30bfff  com.apple.CoreServices.CarbonCore (1217 - 1217) <7AA0ECB3-0993-3081-A9EC-0365EF72B24D> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
    0x7fff3d30c000 -     0x7fff3d359ff1  com.apple.DictionaryServices (1.2 - 321) <3D0FFBDE-E425-37C7-B780-39A3D024462A> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices
    0x7fff3d35a000 -     0x7fff3d362ff7  com.apple.CoreServices.FSEvents (1268.0.6 - 1268.0.6) <78D2AB1A-9053-3D32-8C18-C1DD31FF9400> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/FSEvents.framework/Versions/A/FSEvents
    0x7fff3d363000 -     0x7fff3d59bff1  com.apple.LaunchServices (1069.2 - 1069.2) <68B4C10C-D536-33E9-9719-E7BA5B753F2B> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
    0x7fff3d59c000 -     0x7fff3d634ff1  com.apple.Metadata (10.7.0 - 2066.12) <249EA615-8446-3A36-B6B7-ED613C8B8148> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata
    0x7fff3d635000 -     0x7fff3d662ff7  com.apple.CoreServices.OSServices (1069.2 - 1069.2) <2FECF3BA-B785-35E2-85E9-2A2267801AA4> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
    0x7fff3d663000 -     0x7fff3d6cafff  com.apple.SearchKit (1.4.1 - 1.4.1) <0068BD72-CF2B-34E4-B461-002D5E56C31C> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
    0x7fff3d6cb000 -     0x7fff3d6efffd  com.apple.coreservices.SharedFileList (131 - 131) <61F62948-4109-38F0-BB91-5EBB6BEEAB10> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SharedFileList.framework/Versions/A/SharedFileList
    0x7fff3df44000 -     0x7fff3df4aff7  com.apple.DiskArbitration (2.7 - 2.7) <23104F29-F120-354B-97BE-4514A675BB14> /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
    0x7fff3e277000 -     0x7fff3e63eff3  com.apple.Foundation (6.9 - 1671.15) <4BEAB72D-10AA-3009-B0F5-B82B4FE1C441> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
    0x7fff3e990000 -     0x7fff3ea33ffb  com.apple.framework.IOKit (2.0.2 - 1726.11.1) <9E81E92C-7EC2-330F-B0AF-BBFD9D3E46F6> /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
    0x7fff42284000 -     0x7fff42290ffe  com.apple.NetFS (6.0 - 4.0) <10ECF7E4-98A5-3751-B7AC-0AAAF0050777> /System/Library/Frameworks/NetFS.framework/Versions/A/NetFS
    0x7fff44e54000 -     0x7fff44e70fff  com.apple.CFOpenDirectory (10.15 - 220.11.1) <6F4D018B-FA8B-35B2-8120-F8215DDA01CB> /System/Library/Frameworks/OpenDirectory.framework/Versions/A/Frameworks/CFOpenDirectory.framework/Versions/A/CFOpenDirectory
    0x7fff44e71000 -     0x7fff44e7cfff  com.apple.OpenDirectory (10.15 - 220.11.1) <170173C2-DF22-3D11-914F-465AA7C4760A> /System/Library/Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory
    0x7fff481fe000 -     0x7fff48542ff9  com.apple.security (7.0 - 59306.11.20) <1B0AE660-0EC5-3497-ACE8-1AF2BB772BAB> /System/Library/Frameworks/Security.framework/Versions/A/Security
    0x7fff48543000 -     0x7fff485cbff7  com.apple.securityfoundation (6.0 - 55236) <903B8365-1F35-3EB2-9821-9D2C440BE2DD> /System/Library/Frameworks/SecurityFoundation.framework/Versions/A/SecurityFoundation
    0x7fff48624000 -     0x7fff48628ff8  com.apple.xpc.ServiceManagement (1.0 - 1) <EF42F840-AF78-38A4-B6E1-FDF445CA3477> /System/Library/Frameworks/ServiceManagement.framework/Versions/A/ServiceManagement
    0x7fff49412000 -     0x7fff4947cff7  com.apple.SystemConfiguration (1.19 - 1.19) <C0C089C3-FC64-3107-B23E-4073E800C5D2> /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
    0x7fff4d1d0000 -     0x7fff4d294ff7  com.apple.APFS (1412.11.7 - 1412.11.7) <71DAB6CE-FF14-373D-A183-F388C5D9FE84> /System/Library/PrivateFrameworks/APFS.framework/Versions/A/APFS
    0x7fff4ec95000 -     0x7fff4eca4fdf  com.apple.AppleFSCompression (119 - 1.0) <725908C4-7585-3AB6-8A1A-691B8A9074B8> /System/Library/PrivateFrameworks/AppleFSCompression.framework/Versions/A/AppleFSCompression
    0x7fff50430000 -     0x7fff50439ff3  com.apple.coreservices.BackgroundTaskManagement (1.0 - 104) <156CFAE3-07D0-332C-90BE-BB2E4C893C99> /System/Library/PrivateFrameworks/BackgroundTaskManagement.framework/Versions/A/BackgroundTaskManagement
    0x7fff5317a000 -     0x7fff5318aff3  com.apple.CoreEmoji (1.0 - 100) <9AB89183-635C-3859-9DC6-7BCE3A94D15E> /System/Library/PrivateFrameworks/CoreEmoji.framework/Versions/A/CoreEmoji
    0x7fff537d6000 -     0x7fff53840ff8  com.apple.CoreNLP (1.0 - 211) <8F08AEF6-A380-3811-BAF0-D80E7C84B5AD> /System/Library/PrivateFrameworks/CoreNLP.framework/Versions/A/CoreNLP
    0x7fff54450000 -     0x7fff5447eff7  com.apple.CSStore (1069.2 - 1069.2) <5E3C50AB-9C00-36F3-A986-CE033480CA8B> /System/Library/PrivateFrameworks/CoreServicesStore.framework/Versions/A/CoreServicesStore
    0x7fff60416000 -     0x7fff604e3ffd  com.apple.LanguageModeling (1.0 - 212) <A9F41C84-E574-3624-8C00-60F228E0FF97> /System/Library/PrivateFrameworks/LanguageModeling.framework/Versions/A/LanguageModeling
    0x7fff604e4000 -     0x7fff6052cff7  com.apple.Lexicon-framework (1.0 - 70) <BEADF30C-37D3-3112-90DA-18A85406DBF3> /System/Library/PrivateFrameworks/Lexicon.framework/Versions/A/Lexicon
    0x7fff60533000 -     0x7fff60537ff6  com.apple.LinguisticData (1.0 - 349) <A392AD13-9AEB-31BB-A9ED-F29437CFBDB4> /System/Library/PrivateFrameworks/LinguisticData.framework/Versions/A/LinguisticData
    0x7fff61968000 -     0x7fff619b4ff7  com.apple.spotlight.metadata.utilities (1.0 - 2066.12) <989018A3-4BD0-3FD1-9A2D-88FD3A521452> /System/Library/PrivateFrameworks/MetadataUtilities.framework/Versions/A/MetadataUtilities
    0x7fff623d7000 -     0x7fff623e1fff  com.apple.NetAuth (6.2 - 6.2) <90F9ADF4-8A9C-3603-8F55-24F8C472430B> /System/Library/PrivateFrameworks/NetAuth.framework/Versions/A/NetAuth
    0x7fff6b072000 -     0x7fff6b082ff3  com.apple.TCC (1.0 - 1) <DCE1D8C7-7BEB-3201-A0E5-38F012E6B1BC> /System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC
    0x7fff6f2c2000 -     0x7fff6f2c4ff3  com.apple.loginsupport (1.0 - 1) <40974390-AFD7-3CEF-8B8D-6219BF916A4E> /System/Library/PrivateFrameworks/login.framework/Versions/A/Frameworks/loginsupport.framework/Versions/A/loginsupport
    0x7fff6f632000 -     0x7fff6f667ff7  libCRFSuite.dylib (48) <45ADF347-A43F-3E95-BF26-94DC525DCC81> /usr/lib/libCRFSuite.dylib
    0x7fff6f66a000 -     0x7fff6f674ff3  libChineseTokenizer.dylib (34) <94E822B6-F850-33C5-888C-D5C8AE12122C> /usr/lib/libChineseTokenizer.dylib
    0x7fff6f701000 -     0x7fff6f703fff  libDiagnosticMessagesClient.dylib (112) <418D550B-C748-3D55-A6D5-0398E032F9F3> /usr/lib/libDiagnosticMessagesClient.dylib
    0x7fff6fbc8000 -     0x7fff6fbc9ff3  libSystem.B.dylib (1281) <66742D2E-591A-32B2-8E92-4A54BEE843F6> /usr/lib/libSystem.B.dylib
    0x7fff6fc59000 -     0x7fff6fc5afff  libThaiTokenizer.dylib (3) <D2A89215-5281-310F-8C75-47F1E6A14F62> /usr/lib/libThaiTokenizer.dylib
    0x7fff6fc72000 -     0x7fff6fc88fff  libapple_nghttp2.dylib (1.39.2) <0A685DAA-9FC6-3C87-83F1-1D11FC87C1F4> /usr/lib/libapple_nghttp2.dylib
    0x7fff6fcbd000 -     0x7fff6fd2fff7  libarchive.2.dylib (72.11.2) <8636AE5A-0CBB-306C-8A4B-2E612D2D6B13> /usr/lib/libarchive.2.dylib
    0x7fff6fdca000 -     0x7fff6fdcaff3  libauto.dylib (187) <AACF68BC-9A05-36F8-8F60-78951422E090> /usr/lib/libauto.dylib
    0x7fff6fe88000 -     0x7fff6fe98fff  libbsm.0.dylib (60) <F03FA480-0B22-3300-833F-03E88F43C504> /usr/lib/libbsm.0.dylib
    0x7fff6fe99000 -     0x7fff6fea5fff  libbz2.1.0.dylib (44) <8B522880-BEF8-3668-B785-F2AB4DE8F366> /usr/lib/libbz2.1.0.dylib
    0x7fff6fea6000 -     0x7fff6fef9fff  libc++.1.dylib (800.6) <328FB687-2363-38B1-AC11-11736925C775> /usr/lib/libc++.1.dylib
    0x7fff6fefa000 -     0x7fff6ff0efff  libc++abi.dylib (800.7) <02753D3D-91C6-3670-8B5D-EBE040B516FC> /usr/lib/libc++abi.dylib
    0x7fff6ff0f000 -     0x7fff6ff0fffb  libcharset.1.dylib (59) <12D52FA5-EBCA-3F3C-A269-1095F268F92F> /usr/lib/libcharset.1.dylib
    0x7fff6ff10000 -     0x7fff6ff21ffb  libcmph.dylib (8) <7DD1F726-F3E3-341A-AFAC-83E9A470883C> /usr/lib/libcmph.dylib
    0x7fff6ff22000 -     0x7fff6ff39fe7  libcompression.dylib (87) <10B82884-BE1A-3A36-9B38-3C92AF566D3E> /usr/lib/libcompression.dylib
    0x7fff701fb000 -     0x7fff70211fff  libcoretls.dylib (167) <1C64EA6F-8E0D-319D-99D4-026150EEB2B2> /usr/lib/libcoretls.dylib
    0x7fff70212000 -     0x7fff70213ffb  libcoretls_cfhelpers.dylib (167) <724B0181-4D9E-3D2F-B1AB-B4FD6A7BAB2C> /usr/lib/libcoretls_cfhelpers.dylib
    0x7fff7093c000 -     0x7fff7093cff3  libenergytrace.dylib (21) <E42B4AFF-3FAC-3CE4-A7BF-48621458B356> /usr/lib/libenergytrace.dylib
    0x7fff70964000 -     0x7fff70966ff7  libfakelink.dylib (149) <FC5712CB-2188-3DAD-8DD4-CC3ECCA3F9A8> /usr/lib/libfakelink.dylib
    0x7fff70975000 -     0x7fff7097afff  libgermantok.dylib (24) <93E95178-E436-3611-A4A3-CB1D42CF4064> /usr/lib/libgermantok.dylib
    0x7fff70980000 -     0x7fff70a70ff7  libiconv.2.dylib (59) <1A648E74-25D4-3F9B-94C4-10B58AD091B7> /usr/lib/libiconv.2.dylib
    0x7fff70a71000 -     0x7fff70cc9ff7  libicucore.A.dylib (64232.0.1) <88E47471-605C-3C86-871B-5D2F4628A936> /usr/lib/libicucore.A.dylib
    0x7fff70ce3000 -     0x7fff70ce4fff  liblangid.dylib (133) <78DF87EE-CDCE-3628-B239-56743169BC93> /usr/lib/liblangid.dylib
    0x7fff70ce5000 -     0x7fff70cfdffb  liblzma.5.dylib (16) <D416FC97-76EC-38B5-A134-85DDFEA9D297> /usr/lib/liblzma.5.dylib
    0x7fff70d15000 -     0x7fff70dbcfff  libmecab.dylib (879) <DD60E6AA-154E-3294-B2C0-3277B754F3BC> /usr/lib/libmecab.dylib
    0x7fff70dbd000 -     0x7fff7101cfe9  libmecabra.dylib (879) <B5BE574C-DD3A-336D-87A3-202CE7803A45> /usr/lib/libmecabra.dylib
    0x7fff714db000 -     0x7fff7194dff6  libnetwork.dylib (1880.11.2) <CC02BF51-A056-3656-B735-E8CD0F4B7B15> /usr/lib/libnetwork.dylib
    0x7fff719eb000 -     0x7fff71a1cfe6  libobjc.A.dylib (779.1) <722C0959-69B8-3843-B5EA-CDD8FAA91D5E> /usr/lib/libobjc.A.dylib
    0x7fff71a2f000 -     0x7fff71a33fff  libpam.2.dylib (25) <86317F48-E926-30AC-AE9F-ABB33543FBC8> /usr/lib/libpam.2.dylib
    0x7fff71a36000 -     0x7fff71a69ff7  libpcap.A.dylib (89.11.2) <65A8EBD2-F059-353B-9538-20D1314EFD89> /usr/lib/libpcap.A.dylib
    0x7fff71aeb000 -     0x7fff71b03ff7  libresolv.9.dylib (67) <06480BFC-6372-3225-B77A-F5AC9969DB64> /usr/lib/libresolv.9.dylib
    0x7fff71b5e000 -     0x7fff71d4bff7  libsqlite3.dylib (308.1) <7033723E-DD65-3AA3-ADCA-8746F7BAD75D> /usr/lib/libsqlite3.dylib
    0x7fff71f9a000 -     0x7fff71f9dffb  libutil.dylib (57) <844B7887-09B3-3D12-ACDE-C4EB8F53DC62> /usr/lib/libutil.dylib
    0x7fff71f9e000 -     0x7fff71fabfff  libxar.1.dylib (420) <E0D7C0A6-76EC-3682-A393-6596D4986269> /usr/lib/libxar.1.dylib
    0x7fff71fb1000 -     0x7fff72093ff7  libxml2.2.dylib (32.12) <C0A87484-D334-3B50-8F8A-A9C63295F49E> /usr/lib/libxml2.2.dylib
    0x7fff72097000 -     0x7fff720bffff  libxslt.1.dylib (16.6) <CD9E79B0-159A-3055-B62A-57AB2B445912> /usr/lib/libxslt.1.dylib
    0x7fff720c0000 -     0x7fff720d2fff  libz.1.dylib (76) <3FC3FC3E-ABF3-3167-9078-B54C952608B4> /usr/lib/libz.1.dylib
    0x7fff72b37000 -     0x7fff72b3cff7  libcache.dylib (83) <8EC69760-6DAA-3068-9372-F1D554C548E5> /usr/lib/system/libcache.dylib
    0x7fff72b3d000 -     0x7fff72b48ff7  libcommonCrypto.dylib (60165) <698BE754-137D-361D-B826-57B8DD969E4A> /usr/lib/system/libcommonCrypto.dylib
    0x7fff72b49000 -     0x7fff72b50fff  libcompiler_rt.dylib (101.2) <0BE7F119-C9C2-3612-A3F4-2336D4444476> /usr/lib/system/libcompiler_rt.dylib
    0x7fff72b51000 -     0x7fff72b5aff7  libcopyfile.dylib (166) <B5E73B1C-0BCF-33FE-80A1-D9E3BA3033D4> /usr/lib/system/libcopyfile.dylib
    0x7fff72b5b000 -     0x7fff72bf2fc3  libcorecrypto.dylib (866.0.10) <58344B13-CD10-3697-A516-6F5B06DD1EB7> /usr/lib/system/libcorecrypto.dylib
    0x7fff72d09000 -     0x7fff72d4aff0  libdispatch.dylib (1173.0.3) <F4260D89-F67D-30CB-AF61-7ED25CB687DB> /usr/lib/system/libdispatch.dylib
    0x7fff72d4b000 -     0x7fff72d80fff  libdyld.dylib (732.8) <98960E27-A08B-36DA-A5CB-8538B2D6757E> /usr/lib/system/libdyld.dylib
    0x7fff72d81000 -     0x7fff72d81ffb  libkeymgr.dylib (30) <682B41BC-BDC2-38D5-8820-87099606FA12> /usr/lib/system/libkeymgr.dylib
    0x7fff72d82000 -     0x7fff72d8eff7  libkxld.dylib (6153.11.26) <53BE9630-BDC8-3649-8709-7A4F86777B1A> /usr/lib/system/libkxld.dylib
    0x7fff72d8f000 -     0x7fff72d8fff7  liblaunch.dylib (1738.11.1) <7FE11F0D-65BC-3726-B1DD-E84F329193E0> /usr/lib/system/liblaunch.dylib
    0x7fff72d90000 -     0x7fff72d95ff7  libmacho.dylib (949.0.1) <163DFE06-2FAD-3CBC-80EF-C38EED6AEA52> /usr/lib/system/libmacho.dylib
    0x7fff72d96000 -     0x7fff72d98ff3  libquarantine.dylib (110.0.4) <C8F39330-8CB5-30B0-8564-96453DCEFAD7> /usr/lib/system/libquarantine.dylib
    0x7fff72d99000 -     0x7fff72d9aff7  libremovefile.dylib (48) <FB280185-B5ED-3F08-B08A-A378865C1398> /usr/lib/system/libremovefile.dylib
    0x7fff72d9b000 -     0x7fff72db2fff  libsystem_asl.dylib (377.0.1) <30CE9DAF-B1FA-3510-832B-F1CE19933ED7> /usr/lib/system/libsystem_asl.dylib
    0x7fff72db3000 -     0x7fff72db3fff  libsystem_blocks.dylib (74) <E0B8C825-E62B-357E-A2A0-13776F0A0F8C> /usr/lib/system/libsystem_blocks.dylib
    0x7fff72db4000 -     0x7fff72e3bff7  libsystem_c.dylib (1353.11.2) <2A5BFAFE-8214-3B35-AD46-C07A1A8B8941> /usr/lib/system/libsystem_c.dylib
    0x7fff72e3c000 -     0x7fff72e3ffff  libsystem_configuration.dylib (1061.0.2) <56174463-22ED-337F-B0D4-94995DCDB9B7> /usr/lib/system/libsystem_configuration.dylib
    0x7fff72e40000 -     0x7fff72e43ff7  libsystem_coreservices.dylib (114) <01695913-028E-3AE1-8D4E-2B2769109811> /usr/lib/system/libsystem_coreservices.dylib
    0x7fff72e44000 -     0x7fff72e4bfff  libsystem_darwin.dylib (1353.11.2) <4CE52C63-87AA-3C6D-899F-8C983E5FC061> /usr/lib/system/libsystem_darwin.dylib
    0x7fff72e4c000 -     0x7fff72e53ffb  libsystem_dnssd.dylib (1096.0.2) <DC7381E8-F09F-3441-8267-9B8F50A0EBA9> /usr/lib/system/libsystem_dnssd.dylib
    0x7fff72e54000 -     0x7fff72e55ffb  libsystem_featureflags.dylib (17) <DBCA4AA2-CA05-38D5-AB4B-BE0F3E09BB8B> /usr/lib/system/libsystem_featureflags.dylib
    0x7fff72e56000 -     0x7fff72ea3ff7  libsystem_info.dylib (538) <9F9D6368-A11E-32F1-9BB5-C153F42EFED8> /usr/lib/system/libsystem_info.dylib
    0x7fff72ea4000 -     0x7fff72ed0fff  libsystem_kernel.dylib (6153.11.26) <4CE9D54A-A975-348E-B878-EE74EDFC956B> /usr/lib/system/libsystem_kernel.dylib
    0x7fff72ed1000 -     0x7fff72f18ff7  libsystem_m.dylib (3178) <4F516261-0C0E-3105-AF35-EF39D6347B50> /usr/lib/system/libsystem_m.dylib
    0x7fff72f19000 -     0x7fff72f40fff  libsystem_malloc.dylib (283) <02925539-3CBA-39EB-BA6B-9A936CFA0BF8> /usr/lib/system/libsystem_malloc.dylib
    0x7fff72f41000 -     0x7fff72f4eff3  libsystem_networkextension.dylib (1095.11.9) <8B5EE189-E3D1-31FD-878F-50286B6E7047> /usr/lib/system/libsystem_networkextension.dylib
    0x7fff72f4f000 -     0x7fff72f58fff  libsystem_notify.dylib (241) <89381127-2A07-3F07-B865-358FACCF9102> /usr/lib/system/libsystem_notify.dylib
    0x7fff72f59000 -     0x7fff72f62fe7  libsystem_platform.dylib (220) <90E508E4-46D8-33FF-8552-DDAA079977A0> /usr/lib/system/libsystem_platform.dylib
    0x7fff72f63000 -     0x7fff72f6dfff  libsystem_pthread.dylib (416.11.1) <2EA6F95F-F264-30B6-8AF2-24197B5AED84> /usr/lib/system/libsystem_pthread.dylib
    0x7fff72f6e000 -     0x7fff72f72ffb  libsystem_sandbox.dylib (1217.11.16) <51129CBB-BC46-37F1-A1B5-ECFA9530704D> /usr/lib/system/libsystem_sandbox.dylib
    0x7fff72f73000 -     0x7fff72f75fff  libsystem_secinit.dylib (62.0.4) <A48D9AF3-75F2-3331-A0C8-0A23771F4AC7> /usr/lib/system/libsystem_secinit.dylib
    0x7fff72f76000 -     0x7fff72f7dffb  libsystem_symptoms.dylib (1238.0.2) <08E8CF75-5F77-3475-A48E-A01CBDF09173> /usr/lib/system/libsystem_symptoms.dylib
    0x7fff72f7e000 -     0x7fff72f94ff2  libsystem_trace.dylib (1147.0.3) <5836645E-9862-326D-AB3B-A19E76BE29B9> /usr/lib/system/libsystem_trace.dylib
    0x7fff72f96000 -     0x7fff72f9bffb  libunwind.dylib (35.4) <F5AE1D43-7C5F-3BA2-94D3-E769F82C0F61> /usr/lib/system/libunwind.dylib
    0x7fff72f9c000 -     0x7fff72fd0ff6  libxpc.dylib (1738.11.1) <2E9076CD-6C0E-38B6-8403-B2DDCE125FBF> /usr/lib/system/libxpc.dylib

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 497
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=418.9M resident=0K(0%) swapped_out_or_unallocated=418.9M(100%)
Writable regions: Total=85.1M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=85.1M(100%)
 
                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Kernel Alloc Once                    8K        1 
MALLOC                            76.8M       31 
MALLOC guard page                   16K        4 
Stack                             8188K        1 
Stack Guard                       56.0M        1 
VM_ALLOCATE                        132K        2 
__DATA                            6009K      121 
__DATA_CONST                       188K        2 
__LINKEDIT                       348.9M        3 
__OBJC_RO                         31.8M        1 
__OBJC_RW                         1764K        2 
__TEXT                            70.0M      121 
__UNICODE                          564K        1 
shared memory                        8K        2 
===========                     =======  ======= 
TOTAL                            600.0M      293 

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 13
  • Comments: 30 (5 by maintainers)

Commits related to this issue

Most upvoted comments

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.

dyld is indeed involved in the process, but the root cause is really the -fstack-check. Even when the dyld code path is changed by using -bind_at_load, the issue can appear in other code paths (we’ve seen it in 23 packages so far out of 4000 in Homebrew).

On the other hand, updating the oniguruma submodule to master and compiling produces a working binary!

➜ bin/bat -p test.rb
#! /bin/usr/env ruby

class HelloWorld
  def run!
    puts "Hello world!"
  end
end

HelloWorld.new.run!

I added the following to the brew recipe:

ENV.append "RUSTFLAGS", "-Clink-args=-Wl,-bind_at_load"

Appears to be what was needed.

Had to reinstall bat via Homebrew, but it seems the issue has been fixed. Closing this issue.

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).

brew uninstall bat brew install -s bat

This fixed the issue for me, and as a side bonus I now have rust installed

@sharkdp Homebrew has been updated so it can be closed.

According to this post, -fstack-check is the default option given to clang for macOS 10.15.x. I’m not sure if this affects rustc used to compile bat, however the disassembly of match_at function contains a function call to ___chkstk_darwin, which was added by the above option in clang.

% 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 r10 register was overwritten to a pointer to somewhere on the stack (0x7FEF…) during the function call (or during the dynamic binding). Then, the CPU continues execution and tries to jmp to a non-executable stack, so SIGSEGV occurs.
I overwrote bat binary itself to substitute 5-byte callq 0x1002a0402 instruction into nop; nop; nop; nop; nop. Then, bat successfully read the input from stdin (or pipe).

shell

I believe bat works fine if we can elminate calls to ___chkstk_darwin (as a temporary workaround, at least). I’m completely new to rust, but is it possible to disable -fstack-check option or similar in rustc?

BTW, bat --list-themes also crashed with bat version 0.12.1.

$ bat --list-themes Theme: 1337

Segmentation fault: 11

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).

brew uninstall bat brew install -s bat

Not sure if it’s regarding the same problem, but just updated to Catalina and echo hi | bat returns the same segmentation fault as @davidarmstronglewis reported

Just tried it and it’s still segfault’ing on my side.

Same here, but then I updated Xcode to 11.2.1 and now reinstalling from source works.

As a side note, I’m curious why -fstack-check is clobbering r10. If I remember correctly, it should be a caller-saved register. Is it not being saved before the call to ___chkstk_darwin?

r10 is call-clobbered (== caller-saved) register according to x86-64 SYSV ABI, which macOS follows. Thus, it’s caller’s responsibility to save its value before it calls another function. In theory, compilers should emit the code to save r10 if it notices the register is going to be overwritten.


One thing I need to correct is that this odd behaviour is not because of ___chkstk_darwin, but due to dyld’s resolution of lazy symbol pointer to ___chkstk_darwin. I continued debugging with LLDB and discovered r10 was clobbered during the lazy binding step. Then I tried to force dyld to bind lazy symbol pointers at load time by setting special environment variable DYLD_BIND_AT_LAUNCH. Voila, bat was executed without errors!

$ /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 dyld, there are little things we can do to fix them. IMO, compilers cannot know dyld’s such behaviour, so that it does not emit code which saves r10 on compilation. If so, until @[a]pple fixes the problems, we can copy from builds for older macOSes or build from source as @joevo mentioned (I don’t know why the latter also works though).

Just tried it and it’s still segfault’ing on my side. On Nov 11, 2019, 9:25 AM +0800, Ethan P. notifications@github.com, 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.

Maybe someone could test a modified version of the rust wrapper?

Ok, so I:

  • Cloned rust-onig
  • Updated oniguruma submodule to latest release
  • Build bat using local clone for onig and onig_sys crates.
➜ bin/bat -p test.rb
[1]    95207 segmentation fault  bin/bat -p test.rb

The issue remains.

Could one of you please try to run some example programs from oniguruma?

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). Master right now is pointing to oniguruma:565e5f43c2f9fb9905819ca3eb76114aea267890, 21st of August and there has been quite a few commits since that date too. Maybe someone could test a modified version of the rust wrapper?