mas-cli / mas

:package: Mac App Store command line interface
MIT License
10.82k stars 272 forks source link

segmentation fault: mas list #82

Closed berstend closed 5 years ago

berstend commented 7 years ago

Hi there, all mas commands run fine with the exception of mas list, which is seg faulting.

Any way to help debugging without compiling from source? 😊

❯❯❯ mas version
1.3.1

❯❯❯ mas account
-stripped-

❯❯❯ mas list
[1]    5424 segmentation fault  mas list

Resetting or signin/signout does not fix it.

Thanks!

lwolfsonkin commented 7 years ago

I'm getting the same problem. I just installed mas and this is what I get:

$ mas version
1.3.1
$ mas list
408981381 iPhoto (9.6.1)
682658836 GarageBand (10.1.2)
408981434 iMovie (10.1.2)
497799835 Xcode (7.3.1)
409201541 Pages (5.6.2)
409183694 Keynote (6.6.2)
fish: 'mas list' terminated by signal SIGSEGV (Address boundary error)
mindrunner commented 7 years ago

I can confirm this partly. In some situations, this happens (atm. packer+ansible), but provisioning a Vagrant box with ansible, it does not crash. No clue what the difference is. Might also be some random memory access bug :/ Anyone already debugging this?

edrozenberg commented 7 years ago

Same issue here, segfaulting on a couple different machines, both on 10.12.6. Guessing some recent Sierra update has led to the problem.

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

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [0]
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   mas                             0x000000010527d531 swift::_swift_getClass(void const*) + 33
1   mas                             0x000000010524af68 findDynamicValueAndType(swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::OpaqueValue*&, swift::TargetMetadata<swift::InProcess> const*&, bool&, bool) + 248
2   mas                             0x000000010524ae60 swift_getDynamicType + 32
3   mas                             0x0000000105111357 _TFs15_print_unlockedu0_R_s16TextOutputStreamrFTxRq__T_ + 55
4   mas                             0x0000000104f6c006 _TTSf4d_d___TFV3mas11ListCommand3runfGVS_9NoOptionsOS_8MASError_GOS_6ResultT_S2__ + 886
5   mas                             0x0000000104f6bc5a _TTWV3mas11ListCommandS_15CommandProtocolS_FS1_3runfwx7OptionsGOS_6ResultT_wx11ClientError_ + 42
6   mas                             0x0000000104f59488 _TFFV3mas14CommandWrappercuRd__S_15CommandProtocolxzWd__7Options11ClientError_wd__11ClientErrorzWd__S2_S3__rFqd__GS0_x_U_FCS_14ArgumentParserGOS_6ResultT_GOS_15CommandantErrorQ___ + 1176
7   mas                             0x0000000104f5ca98 _TPA__TFFV3mas14CommandWrappercuRd__S_15CommandProtocolxzWd__7Options11ClientError_wd__11ClientErrorzWd__S2_S3__rFqd__GS0_x_U_FCS_14ArgumentParserGOS_6ResultT_GOS_15CommandantErrorQ___ + 88
8   mas                             0x0000000104f5a042 _TFC3mas15CommandRegistry3runfT7commandSS9argumentsGSaSS__GSqGOS_6ResultT_GOS_15CommandantErrorx___ + 274
9   mas                             0x0000000104f5a512 _TFC3mas15CommandRegistry4mainfT9argumentsGSaSS_11defaultVerbSS12errorHandlerFxT__Os5Never + 466
10  mas                             0x0000000104f5a337 _TFC3mas15CommandRegistry4mainfT11defaultVerbSS12errorHandlerFxT__Os5Never + 135
11  mas                             0x0000000104f6cc40 main + 944
12  libdyld.dylib                   0x00007fffe6622235 start + 1
Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x00007ffffffffff8  rbx: 0x00000001057b3068  rcx: 0x000000000000000e  rdx: 0x00007fff5acb61e8
  rdi: 0x0000000000000000  rsi: 0x00000001057b3068  rbp: 0x00007fff5acb6170  rsp: 0x00007fff5acb6168
   r8: 0x00007fff5acb61df   r9: 0x0000000000000000  r10: 0x00007fffeeda4168  r11: 0x00007f90e5c0bc00
  r12: 0x00007fff5acb61e8  r13: 0x00007fff5acb6428  r14: 0x00007fff5acb61e0  r15: 0x000000010524af98
  rip: 0x000000010527d531  rfl: 0x0000000000010246  cr2: 0x0000000000000000

Logical CPU:     0
Error Code:      0x00000004
Trap Number:     14
lwolfsonkin commented 7 years ago

I'm still on El Capitán, so I don't think it's a Sierra bug necessarily.

2017-08-25 19:55 GMT-04:00 Eduard Rozenberg notifications@github.com:

Same issue here, segfaulting on a couple different machines, both on 10.12.6. Guessing some recent Sierra update has led to the problem.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mas-cli/mas/issues/82#issuecomment-325059349, or mute the thread https://github.com/notifications/unsubscribe-auth/AP6uVsPh5aopHSP0uiyF7BAA88JmjakAks5sb17dgaJpZM4Mhn4w .

mraerino commented 6 years ago

I'm also getting this one. Anything I can do to help solving this?

wesbaker commented 6 years ago

For the folks that have this, do you have a macOS installer downloaded? I think that was my problem. When I attempted to run mas list, this is what I got:

$ mas list                                                                                                                                                                      (254ms)
1063661581 Renamer 5 (5.1.0)
931657367 Calcbot (1.0.6)
1081413713 GIF Brewery 3 (3.6)
880001334 Reeder (3.0.5)
451907568 Paprika Recipe Manager (2.2.0)
407963104 Pixelmator (3.7)
497799835 Xcode (9.0)
585829637 Todoist (7.0.3)
557168941 Tweetbot (2.5.3)
1263070803 Lungo (1.3.0)
924726344 Deliveries (3.0.5)
1017470484 Next Meeting (1.9.2)
889428659 xScope (4.3)
425424353 The Unarchiver (3.11.3)
1179623856 Pastebot (2.1.4)
fish: 'mas list' terminated by signal SIGSEGV (Address boundary error)

When I compiled from source and ran it, I got this (notice what's below Pastebot):

./build/mas list                                                                                                                                                                 (10s 79ms)
1063661581 Renamer 5 (5.1.0)
931657367 Calcbot (1.0.6)
1081413713 GIF Brewery 3 (3.6)
880001334 Reeder (3.0.5)
451907568 Paprika Recipe Manager (2.2.0)
407963104 Pixelmator (3.7)
497799835 Xcode (9.0)
585829637 Todoist (7.0.3)
557168941 Tweetbot (2.5.3)
1263070803 Lungo (1.3.0)
924726344 Deliveries (3.0.5)
1017470484 Next Meeting (1.9.2)
889428659 xScope (4.3)
425424353 The Unarchiver (3.11.3)
1179623856 Pastebot (2.1.4)
0 Install macOS High Sierra (13.0.64)
419330170 Moom (3.2.9)
420212497 Byword (2.8.1)
873245660 Spillo (2.0)
890031187 Marked 2 (2.5.10)
409201541 Pages (6.3)
413965349 Soulver (2.6.4)
803453959 Slack (2.8.1)
1055511498 Day One (2.5.1)
942305623 Thessa (1.4)
411643860 DaisyDisk (4.4)
405399194 Kindle (1.20.3)
992076693 MindNode (2.5.5)
409203825 Numbers (4.3)
443987910 1Password (6.8.2)
409183694 Keynote (7.3)
1091189122 Bear (1.3.1)
1107421413 1Blocker (1.4)

So my guess is that the macOS installers (or possibly other apps?) don't have a product.itemIdentifier and we get a segmentation fault.

wesbaker commented 6 years ago

Sure enough, when I delete the installer, mas list works like before.

lwolfsonkin commented 6 years ago

That's very likely it. I have been a hold out on El Capitan, and the new macOS installer is likely there. Great catch, Wes!

בתאריך יום ג׳, 10 באוק׳ 2017 ב-11:39 מאת Wes Baker <notifications@github.com

:

Sure enough, when I delete the installer, mas list works like before.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mas-cli/mas/issues/82#issuecomment-335515056, or mute the thread https://github.com/notifications/unsubscribe-auth/AP6uVt1gmxaKeRC_XfO3lL6zvYYQuF-gks5sq4-ogaJpZM4Mhn4w .

mraerino commented 6 years ago

I can confirm this. I'm on Sierra and recently downloaded the High Sierra installer.

berstend commented 6 years ago

Note sure if this behavior is related to the initial segfault I reported here but in my case the mas list/outdated commands went silent (no more segfault, but also no output).

My system is pretty outdated and I move to a more recent one soon, so I'll add the following for historical purposes only. 😄

~ ❯❯❯ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.11.4
BuildVersion:   15E65

~ ❯❯❯ mas version
1.3.1

~ ❯❯❯ mas account
-- stripped --

~ ❯❯❯ mas search xcode
497799835 Xcode

~ ❯❯❯ mas outdated
⏎

~ ❯❯❯ mas list                                                                                                                                                       ⏎

I most likely had a macOS installer downloaded back when I reported this issue originally, but can't find it currently on my system.

windyinsc commented 6 years ago

Bam! I had this very same issueSegmentation fault: 11 and after I uninstalled my macOS Sierra installer the segmentation fault error was resolved. Hat tip to @wesbaker for the easy fix.

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.12.6
BuildVersion:   16G1036

$ mas version
1.3.1
truwo commented 6 years ago

I could use "mas list" again on High Sierra 10.13.1 after explicitely uninstalling mas via "brew uninstall mas" followed by a "brew install mas" and deleting the "Install macOS High Sierra" App from Applications. Prior to that, I also got a segmentation violation. I hope that this can help you as well bridging the gap until someone takes care of an update of this (beloved and still very useful) project...

exalted commented 6 years ago

Moving “Install macOS High Sierra” to anywhere else will do it just fine. 🤷‍♂️

Nasty stuff… I am glad there‘s a workaround after all, however. 🙇

paulp commented 6 years ago

brew install --HEAD mas is at present sufficient to avoid the seg fault without moving the installer out of the way, so presumably this has been fixed and only awaits a release.

thoke commented 6 years ago

@paulp, what version of the installer is present such that it's working?

My installer had been removed, so I downloaded again and mas list is working just fine:

$ mas version
1.3.1

$ mas list
-->8 snip 8<--
0 Install macOS High Sierra (13.3.02)
409203825 Numbers (4.3.1)
-->8 snip 8<--

At some point before, I too was having the seg fault.

paulp commented 6 years ago

@thoke Current release:

% brew install mas
==> Downloading https://homebrew.bintray.com/bottles/mas-1.3.1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring mas-1.3.1.sierra.bottle.tar.gz
...
% mas list
...
407963104 Pixelmator (3.7)
Segmentation fault: 11

HEAD:

% brew install --HEAD mas
...
% mas list
...
407963104 Pixelmator (3.7)
 Install macOS High Sierra (13105)
...

No dots in my installer version. Maybe it's something silly like it running off the end of the buffer looking for a dot.

paulp commented 6 years ago

@thoke Oh, I just noticed it's also in the list with dots.

407963104 Pixelmator (3.7)
 Install macOS High Sierra (13105)
...
0 Install macOS High Sierra (13.1.05)
...
paulp commented 6 years ago

The relevant code (as mentioned in an earlier comment) is

for product in products {
  print("\(product.itemIdentifier) \(product.appName) (\(product.bundleVersion))")
}

So more than likely the absent itemIdentifier is indeed the cause.

It's possible this has been fixed not by a change in this project, but by a change in the swift compiler. I don't know swift at all, but one can imagine both interpolation behaviors existing in different compiler versions.

paulp commented 6 years ago

Aha.

% brew install --build-from-source mas
% mas version
1.3.1
% mas list
...
407963104 Pixelmator (3.7)
 Install macOS High Sierra (13105)
...
phatblat commented 6 years ago

Is anyone still having this issue with mas 1.4.1? I'm unable to reproduce it.

$ mas version
1.4.1
$ mas list
...
1246284741 Install macOS High Sierra (13.4.08)