kjn / lbzip2

Parallel bzip2 utility
GNU General Public License v3.0
132 stars 17 forks source link

macOS: lbzip2 -v crashes with "illegal hardware instruction" #20

Open dancek opened 6 years ago

dancek commented 6 years ago

Using the parameter -v causes lbzip2 to crash for me. Weirdly after that happens, any call to lbzip2 crashes for a while. After a few minutes (and doing something else) it works again.

$ lbzip2 -v README.md
[1]    80520 illegal hardware instruction  lbzip2 -v README.md
$ lbzip2 README.md
[1]    80755 illegal hardware instruction  lbzip2 README.md

This is on lbzip2 2.5 installed from Homebrew. It's built with ./configure --disable-debug --disable-dependency-tracking in case that matters.

Here's the crash log:

Process:               lbzip2 [80520]
Path:                  /usr/local/Cellar/lbzip2/2.5/bin/lbzip2
Identifier:            lbzip2
Version:               0
Code Type:             X86-64 (Native)
Parent Process:        zsh [70006]
Responsible:           lbzip2 [80520]
User ID:               501

Date/Time:             2018-04-25 12:44:04.527 +0300
OS Version:            Mac OS X 10.13.2 (17C88)
Report Version:        12
Bridge OS Version:     3.0 (14Y661)
Anonymous UUID:        E44E2E84-CDBC-B3B7-16B1-EB8100EA5BA1

Sleep/Wake UUID:       06491AE0-82A8-407A-97AF-E1E3867DB275

Time Awake Since Boot: 1900000 seconds
Time Since Wake:       82000 seconds

System Integrity Protection: enabled

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

Exception Type:        EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes:       0x0000000000000001, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Illegal instruction: 4
Termination Reason:    Namespace SIGNAL, Code 0x4
Terminating Process:   exc handler [0]

Application Specific Information:
%n used in a non-immutable format string

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_c.dylib               0x00007fff6e1f3a0b __vfprintf + 16437
1   libsystem_c.dylib               0x00007fff6e218091 __v2printf + 473
2   libsystem_c.dylib               0x00007fff6e1fd4af _vsnprintf + 415
3   libsystem_c.dylib               0x00007fff6e1fd50c vsnprintf_l + 41
4   libsystem_c.dylib               0x00007fff6e1ee4d4 snprintf + 180
5   lbzip2                          0x000000010dc5a966 vasnprintf + 3094
6   lbzip2                          0x000000010dc58d55 rpl_fprintf + 185
7   lbzip2                          0x000000010dc551f4 log_generic + 61
8   lbzip2                          0x000000010dc5518c info + 170
9   lbzip2                          0x000000010dc576a8 work + 97
10  lbzip2                          0x000000010dc56642 main + 2767
11  libdyld.dylib                   0x00007fff6e15c115 start + 1

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x0000000000000000  rcx: 0x0000050000000000  rdx: 0x0000040000000503
  rdi: 0x0000000000012068  rsi: 0x0000000000000500  rbp: 0x00007ffee1fb59f0  rsp: 0x00007ffee1fb5670
   r8: 0x00007fffa7245da0   r9: 0x0000000000000040  r10: 0x00007fffa7245d98  r11: 0xffffffffffffffff
  r12: 0x00007ffee1fb5dc4  r13: 0x0000000000000000  r14: 0x0000000000000006  r15: 0x00007ffee1fb61f8
  rip: 0x00007fff6e1f3a0b  rfl: 0x0000000000010202  cr2: 0x000000010dc7c000

Logical CPU:     4
Error Code:      0x00000000
Trap Number:     6

Binary Images:
       0x10dc48000 -        0x10dc61fff +lbzip2 (0) <A2637AA1-9432-3466-B680-E2313C060313> /usr/local/bin/lbzip2
       0x1120ed000 -        0x11213798f  dyld (519.2.2) <6695F30B-4E88-3C0B-9867-7D738C44A3E6> /usr/lib/dyld
    0x7fff6ba45000 -     0x7fff6ba78fff  libclosured.dylib (519.2.2) <48051216-5647-3643-B979-B77D0FD20011> /usr/lib/closure/libclosured.dylib
    0x7fff6bf57000 -     0x7fff6bf58ff3  libSystem.B.dylib (1252) <5EDEEA85-0387-31EE-9D9B-DA1B75E7AEF3> /usr/lib/libSystem.B.dylib
    0x7fff6c18b000 -     0x7fff6c1e1fff  libc++.1.dylib (400.9) <FCF5E1F6-2B04-3545-8004-F3AB32FED172> /usr/lib/libc++.1.dylib
    0x7fff6c1e2000 -     0x7fff6c206ff7  libc++abi.dylib (400.7) <217656D5-BC40-37FF-B322-91CB2AAD4F34> /usr/lib/libc++abi.dylib
    0x7fff6d558000 -     0x7fff6d9467e7  libobjc.A.dylib (723) <93A92316-DE1E-378C-8891-99720B50D075> /usr/lib/libobjc.A.dylib
    0x7fff6dff3000 -     0x7fff6dff7ff7  libcache.dylib (80) <354F3B7D-404E-3398-9EBF-65CA2CE65211> /usr/lib/system/libcache.dylib
    0x7fff6dff8000 -     0x7fff6e002ff3  libcommonCrypto.dylib (60118.30.2) <674286D3-7744-36A3-9AAA-49DFCD97A986> /usr/lib/system/libcommonCrypto.dylib
    0x7fff6e003000 -     0x7fff6e00afff  libcompiler_rt.dylib (62) <4487CFBA-A5D7-3282-9E6B-94CAD7BE507E> /usr/lib/system/libcompiler_rt.dylib
    0x7fff6e00b000 -     0x7fff6e013ffb  libcopyfile.dylib (146.30.2) <2C7C67D7-562B-3FFA-973D-BACF4C10E1EC> /usr/lib/system/libcopyfile.dylib
    0x7fff6e014000 -     0x7fff6e099fff  libcorecrypto.dylib (562.30.10) <8A53EFE1-AFCA-3676-BEE1-FA5ED9F0E222> /usr/lib/system/libcorecrypto.dylib
    0x7fff6e121000 -     0x7fff6e15aff7  libdispatch.dylib (913.30.4) <7D0E3183-282B-3FEE-A734-2C0ADC092084> /usr/lib/system/libdispatch.dylib
    0x7fff6e15b000 -     0x7fff6e178ff7  libdyld.dylib (519.2.2) <C50D02BC-A333-3313-B787-02F255A6783F> /usr/lib/system/libdyld.dylib
    0x7fff6e179000 -     0x7fff6e179ffb  libkeymgr.dylib (28) <6D84A96F-C65B-38EC-BDB5-21FD2C97E7B2> /usr/lib/system/libkeymgr.dylib
    0x7fff6e187000 -     0x7fff6e187ff7  liblaunch.dylib (1205.30.29) <E66F58ED-C15E-3DFB-BC22-A861E13918C6> /usr/lib/system/liblaunch.dylib
    0x7fff6e188000 -     0x7fff6e18cffb  libmacho.dylib (900.0.1) <756F2553-07B6-3B42-ACEA-2F0F1A5E8D0F> /usr/lib/system/libmacho.dylib
    0x7fff6e18d000 -     0x7fff6e18fff3  libquarantine.dylib (86) <6AC8773F-3817-3D82-99C2-01BABB9C3CBB> /usr/lib/system/libquarantine.dylib
    0x7fff6e190000 -     0x7fff6e191ff3  libremovefile.dylib (45) <912FA211-DD8C-3C92-8424-21B89F8B10FD> /usr/lib/system/libremovefile.dylib
    0x7fff6e192000 -     0x7fff6e1a9fff  libsystem_asl.dylib (356.1.1) <94972913-9DF0-3C78-847C-43E58919E3DA> /usr/lib/system/libsystem_asl.dylib
    0x7fff6e1aa000 -     0x7fff6e1aafff  libsystem_blocks.dylib (67) <F2493BB5-B1C6-3C4D-9F1F-1B402E0F1DB7> /usr/lib/system/libsystem_blocks.dylib
    0x7fff6e1ab000 -     0x7fff6e234ff7  libsystem_c.dylib (1244.30.3) <E0136C71-0648-36F0-9F84-82EA2748A8D7> /usr/lib/system/libsystem_c.dylib
    0x7fff6e235000 -     0x7fff6e238ffb  libsystem_configuration.dylib (963.30.1) <0F8D0B76-4F7D-34EC-AB6C-50F9465809DA> /usr/lib/system/libsystem_configuration.dylib
    0x7fff6e239000 -     0x7fff6e23cffb  libsystem_coreservices.dylib (51) <21A488D0-2D07-344E-8631-CC8B2A246F35> /usr/lib/system/libsystem_coreservices.dylib
    0x7fff6e23d000 -     0x7fff6e23efff  libsystem_darwin.dylib (1244.30.3) <2F750CB1-BC26-3FA3-AE59-553EE30D451B> /usr/lib/system/libsystem_darwin.dylib
    0x7fff6e23f000 -     0x7fff6e245ff7  libsystem_dnssd.dylib (878.30.4) <EB9BB165-45A4-367C-B33A-688D4F383A95> /usr/lib/system/libsystem_dnssd.dylib
    0x7fff6e246000 -     0x7fff6e28fff7  libsystem_info.dylib (517.30.1) <7D79E167-4B5C-3833-81EE-3AF3FB53616D> /usr/lib/system/libsystem_info.dylib
    0x7fff6e290000 -     0x7fff6e2b5ff7  libsystem_kernel.dylib (4570.31.3) <D2E842AA-3B8D-31BF-8234-8C1BE11CFE32> /usr/lib/system/libsystem_kernel.dylib
    0x7fff6e2b6000 -     0x7fff6e301fcb  libsystem_m.dylib (3146) <ABB1B85F-9FFE-31B8-AD4F-E39A30794A93> /usr/lib/system/libsystem_m.dylib
    0x7fff6e302000 -     0x7fff6e321fff  libsystem_malloc.dylib (140.1.1) <9F0745FF-B92F-330D-8812-BB74001D1D33> /usr/lib/system/libsystem_malloc.dylib
    0x7fff6e322000 -     0x7fff6e3c6ff3  libsystem_network.dylib (1229.30.11) <40BAD301-8744-3AD8-A688-E7925C587B00> /usr/lib/system/libsystem_network.dylib
    0x7fff6e3c7000 -     0x7fff6e3d1ffb  libsystem_networkextension.dylib (767.30.7) <C5ED4BAB-2480-369D-8AB6-DFB37C15A1EE> /usr/lib/system/libsystem_networkextension.dylib
    0x7fff6e3d2000 -     0x7fff6e3dbff3  libsystem_notify.dylib (172) <98EA3D62-7C86-30DE-8261-D020D2F1EFF3> /usr/lib/system/libsystem_notify.dylib
    0x7fff6e3dc000 -     0x7fff6e3e3ff7  libsystem_platform.dylib (161.20.1) <C049250F-8C35-314D-810F-4E28AEAED983> /usr/lib/system/libsystem_platform.dylib
    0x7fff6e3e4000 -     0x7fff6e3effff  libsystem_pthread.dylib (301.30.1) <ABA848E1-6978-3B42-A3A7-608B2C36FA93> /usr/lib/system/libsystem_pthread.dylib
    0x7fff6e3f0000 -     0x7fff6e3f3ff3  libsystem_sandbox.dylib (765.30.4) <A51828BA-26D8-3205-AF3A-DF5C37269468> /usr/lib/system/libsystem_sandbox.dylib
    0x7fff6e3f4000 -     0x7fff6e3f5ff3  libsystem_secinit.dylib (30) <F06ADB8F-9E94-34A7-B3C9-2C22FDD14BAD> /usr/lib/system/libsystem_secinit.dylib
    0x7fff6e3f6000 -     0x7fff6e3fdff7  libsystem_symptoms.dylib (820.30.7) <DC3586C2-AA56-3419-88D3-FC0DBF08E3C0> /usr/lib/system/libsystem_symptoms.dylib
    0x7fff6e3fe000 -     0x7fff6e411ff7  libsystem_trace.dylib (829.30.14) <69EBF017-D40F-30D7-9B0B-BFC862D761A5> /usr/lib/system/libsystem_trace.dylib
    0x7fff6e413000 -     0x7fff6e418ff7  libunwind.dylib (35.3) <6D4FCD49-D2A9-3233-95C7-A7635CE265F2> /usr/lib/system/libunwind.dylib
    0x7fff6e419000 -     0x7fff6e445ff7  libxpc.dylib (1205.30.29) <F7E5F1BC-614B-39CB-B6CE-92A9C7B7EC0B> /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: 19972451
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=197.0M resident=0K(0%) swapped_out_or_unallocated=197.0M(100%)
Writable regions: Total=17.3M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=17.3M(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Kernel Alloc Once                    8K        2 
MALLOC                            9276K        8 
MALLOC guard page                   16K        5 
STACK GUARD                       56.0M        2 
Stack                             8192K        2 
__DATA                            2324K       43 
__LINKEDIT                       188.3M        4 
__TEXT                            8976K       42 
shared memory                        8K        3 
===========                     =======  ======= 
TOTAL                            272.4M      102 
dancek commented 6 years ago

Turns out this is a bug in coreutils' vasnprintf. Sorry for reporting in the wrong place. I'm sending a PR of a patched build soon; expect a working version of lbzip2 in Homebrew in a week.

dancek commented 6 years ago

The issue is in gnulib (rather than coreutils as I previously stated) and I only now realize that lbzip2 in fact ships a copy of gnulib in its tarball. Basically a new release with a fixed version of gnulib is needed to make the crash on macOS 10.13 go away.

The relevant gnulib mailing list thread: http://lists.gnu.org/archive/html/bug-gnulib/2017-07/msg00056.html

dancek commented 6 years ago

I'd make a PR but since lib/ doesn't exist in the git repo there's nothing to edit.

logological commented 5 years ago

In order to work around Issue #22, I have published my own source distribution for lbzip2 2.5 which is bootstrapped using the latest version of gnulib. See my comment on that issue for further details. The distribution probably also works around this issue, though as I don't have macOS I can't check.

ryandesign commented 5 years ago

MacPorts users are experiencing this problem too. Can you please fix it by releasing a new version, with a source tarball built using the fixed version of gnulib?

logological commented 5 years ago

@ryandesign: See my previous comment for a workaround. If you are responsible for the MacPorts package, then you could temporarily switch to my fork.

ryandesign commented 4 years ago

Again: Can you please fix it by releasing a new version, with a source tarball built using the fixed version of gnulib?