Skip to content

Instantly share code, notes, and snippets.

@martinklepsch
Last active October 10, 2019 03:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinklepsch/f221b043cf53f659d955c49685072426 to your computer and use it in GitHub Desktop.
Save martinklepsch/f221b043cf53f659d955c49685072426 to your computer and use it in GitHub Desktop.
`login` blocking indefinitely

More context: https://twitter.com/martinklepsch/status/810483946597158912

$ sudo dtruss login
dtrace: system integrity protection is on, some features will not be available
dtrace: failed to execute login: dtrace cannot control executables signed with restricted entitlements

In my ~/.tmux.conf I had a line like this:

set-option -g default-command "reattach-to-user-namespace -l fish"

I removed it for now in the hope that the issue might be caused by reattach-to-user-namespace somehow.

Also this thread on the Apple support forums does have some good advice for debugging the login process. I assume this is similar to what dtrace would do but hope that it works without disabling SIP/sudo.

I found that, even if "Command (complete path):" is selected (instead of "Default login shell (/usr/bin/login)") the shell is not started directly by Terminal but started via login (as "login -pfq username /path/to/the/shell").

Start Activity Monitor.app, and select "All Processes" from the pop-up menu at the top of the window. Then click onece or twice on the "PID" (title of the left most column of the process list) so that the process list is sorted in the decreasing order of pid (largest pid at the top of the list).

Also start Console.app, and select "All Messages" (or system.log) in in the left pane of the window.

Now start Terminal.app (or open a new window in Terminal). In my case, Activity Monitor shows "login", "zsh" (=my shell) and "taskgated" are started in this order, and taskgated terminates in a 10 seconds or so. Console.app shows the message like

DATE TIME login[62364]: USER_PROCESS: 62364 ttys000

Do you get this kind of log message? Any other messages (errors) in Console.app?

If you think "login" is hanging, then, in Activity Monitor, select the process "login" in the process list, push the "Inspect" button at the top of the window, and push the "Sample" button; you may need to enter the admin password. Then you will see some info about what the "login" is doing now. Does this give any hit about what is going wrong?

Are you using any special settings or third party software which might interfere with the authentication process? (https://discussions.apple.com/message/10541733#message10541733)

Analysis of sampling login (pid 90140) every 1 millisecond
Process: login [90140]
Path: /usr/bin/login
Load Address: 0x1099da000
Identifier: login
Version: 735.30.2
Code Type: X86-64
Parent Process: iTerm2 [90139]
Date/Time: 2016-12-27 01:14:28.886 +0800
Launch Time: 2016-12-27 01:10:39.562 +0800
OS Version: Mac OS X 10.12.2 (16C67)
Report Version: 7
Analysis Tool: /usr/bin/sample
----
Call graph:
2542 Thread_3379546 DispatchQueue_1: com.apple.main-thread (serial)
2542 start (in libdyld.dylib) + 1 [0x7fffa3ec8255]
2542 ??? (in login) load address 0x1099da000 + 0x1729 [0x1099db729]
2542 ttyname (in libsystem_c.dylib) + 239 [0x7fffa3f2d241]
2542 ttyname_r (in libsystem_c.dylib) + 153 [0x7fffa3f2d2e9]
2542 devname_r (in libsystem_c.dylib) + 170 [0x7fffa3f00ec9]
2542 lstat$INODE64 (in libsystem_kernel.dylib) + 10 [0x7fffa3ff7f1a]
Total number in stack (recursive counted multiple, when >=5):
Sort by top of stack, same collapsed (when >= 5):
lstat$INODE64 (in libsystem_kernel.dylib) 2542
Binary Images:
0x1099da000 - 0x1099ddffb +login (735.30.2) <3F5493D6-0836-34BA-9FA9-8A230FD083B2> /usr/bin/login
0x118f82000 - 0x118fbf267 dyld (0.0 - ???) <947FC440-80F9-32F7-A773-6FC418FE1AB7> /usr/lib/dyld
0x7fffa2925000 - 0x7fffa2926ff3 libSystem.B.dylib (1238) <FF55E335-37C3-3567-9415-A3A1473775F5> /usr/lib/libSystem.B.dylib
0x7fffa2a3e000 - 0x7fffa2a3eff3 libauto.dylib (187) <5BBF6A00-CC76-389D-84E7-CA88EDADE683> /usr/lib/libauto.dylib
0x7fffa2a3f000 - 0x7fffa2a4fff3 libbsm.0.dylib (34) <20084796-B04D-3B35-A003-EA11459557A9> /usr/lib/libbsm.0.dylib
0x7fffa2a5f000 - 0x7fffa2ab5ff7 libc++.1.dylib (307.4) <BEE86868-F831-384C-919E-2B286ACFE87C> /usr/lib/libc++.1.dylib
0x7fffa2ab6000 - 0x7fffa2ae0fff libc++abi.dylib (307.2) <1CEF8ABB-7E6D-3C2F-8E0A-E7884478DD23> /usr/lib/libc++abi.dylib
0x7fffa35d0000 - 0x7fffa39a0d97 libobjc.A.dylib (706) <F9AFE665-A3A2-3285-9495-19803A565861> /usr/lib/libobjc.A.dylib
0x7fffa39a3000 - 0x7fffa39a7fff libpam.2.dylib (21.30.1) <71EB0D88-DE84-3C8D-A2C5-58AA282BC5BC> /usr/lib/libpam.2.dylib
0x7fffa3dea000 - 0x7fffa3deeff7 libcache.dylib (79) <0C8092D3-600F-3ADD-A036-F225B6CDCA43> /usr/lib/system/libcache.dylib
0x7fffa3def000 - 0x7fffa3dfaff7 libcommonCrypto.dylib (60092.30.2) <B16E29B6-EC8D-3A8F-9A89-DD9CF35F7C4B> /usr/lib/system/libcommonCrypto.dylib
0x7fffa3dfb000 - 0x7fffa3e02fff libcompiler_rt.dylib (62) <E992E8D9-037C-3454-A366-A25E4D31D6BB> /usr/lib/system/libcompiler_rt.dylib
0x7fffa3e03000 - 0x7fffa3e0bfff libcopyfile.dylib (138) <64E285D9-5485-333B-AEE7-8B0C8FB9275F> /usr/lib/system/libcopyfile.dylib
0x7fffa3e0c000 - 0x7fffa3e8ffdf libcorecrypto.dylib (442.30.20) <2074B932-FD79-30A9-8E90-AF25C49F2AF1> /usr/lib/system/libcorecrypto.dylib
0x7fffa3e90000 - 0x7fffa3ec2fff libdispatch.dylib (703.30.5) <EA0CC14E-D559-3802-B4B2-0E8C7579AAC4> /usr/lib/system/libdispatch.dylib
0x7fffa3ec3000 - 0x7fffa3ec8ff3 libdyld.dylib (421.2) <E5A2414F-2480-3BB2-BE94-176119A80876> /usr/lib/system/libdyld.dylib
0x7fffa3ec9000 - 0x7fffa3ec9ffb libkeymgr.dylib (28) <1A318923-1200-3B06-B432-5007D82F195D> /usr/lib/system/libkeymgr.dylib
0x7fffa3ed7000 - 0x7fffa3ed7fff liblaunch.dylib (972.30.7) <15FACC21-079A-3BDF-9AFB-4253EFDEB587> /usr/lib/system/liblaunch.dylib
0x7fffa3ed8000 - 0x7fffa3eddfff libmacho.dylib (894) <A2F38EC1-C37C-3B93-B0E4-36B07C177F8C> /usr/lib/system/libmacho.dylib
0x7fffa3ede000 - 0x7fffa3ee0ff3 libquarantine.dylib (85) <C1D7749F-5F5F-3BB9-BEFC-1F0B9DA941FD> /usr/lib/system/libquarantine.dylib
0x7fffa3ee1000 - 0x7fffa3ee2ffb libremovefile.dylib (45) <CD42974E-BE0B-39FC-9BFC-8A7540A04DC6> /usr/lib/system/libremovefile.dylib
0x7fffa3ee3000 - 0x7fffa3efbff7 libsystem_asl.dylib (349.30.2) <EFAC72D7-CB13-3DF7-ADF3-EC6635C6F1EA> /usr/lib/system/libsystem_asl.dylib
0x7fffa3efc000 - 0x7fffa3efcff7 libsystem_blocks.dylib (67) <B8C3701D-5A91-3D35-999D-2DC8D5393525> /usr/lib/system/libsystem_blocks.dylib
0x7fffa3efd000 - 0x7fffa3f8afef libsystem_c.dylib (1158.30.7) <2F881962-03CB-3B9D-A782-D98C1BBA4E3D> /usr/lib/system/libsystem_c.dylib
0x7fffa3f8b000 - 0x7fffa3f8effb libsystem_configuration.dylib (888.30.2) <4FE3983C-E4ED-3939-A578-03AD29C99788> /usr/lib/system/libsystem_configuration.dylib
0x7fffa3f8f000 - 0x7fffa3f92fff libsystem_coreservices.dylib (41.4) <1A572B9E-0C47-320F-8C64-7990D0A5FB5A> /usr/lib/system/libsystem_coreservices.dylib
0x7fffa3f93000 - 0x7fffa3fabff3 libsystem_coretls.dylib (121.31.1) <4676F06D-274D-31BE-B61C-4D7A4AEF4858> /usr/lib/system/libsystem_coretls.dylib
0x7fffa3fac000 - 0x7fffa3fb2fff libsystem_dnssd.dylib (765.30.11) <DC708D84-ED7D-3936-B996-A67C66B8DDAA> /usr/lib/system/libsystem_dnssd.dylib
0x7fffa3fb3000 - 0x7fffa3fdcff7 libsystem_info.dylib (503.30.1) <9ED9121C-F111-3FAD-BC2F-C95DEE1C9362> /usr/lib/system/libsystem_info.dylib
0x7fffa3fdd000 - 0x7fffa3fffff7 libsystem_kernel.dylib (3789.31.2) <FCEEBBD4-DF66-34D8-A32F-4F8C8E814E40> /usr/lib/system/libsystem_kernel.dylib
0x7fffa4000000 - 0x7fffa4047fe7 libsystem_m.dylib (3121.4) <266DB92B-A86F-3691-80FB-1B26AD73CFF3> /usr/lib/system/libsystem_m.dylib
0x7fffa4048000 - 0x7fffa4066ff7 libsystem_malloc.dylib (116.30.3) <F40DEE3B-386A-3529-A3F7-98117ED55BF4> /usr/lib/system/libsystem_malloc.dylib
0x7fffa4067000 - 0x7fffa40beffb libsystem_network.dylib (856.30.16) <4AE368E9-605D-379D-B04C-2AC7455B8250> /usr/lib/system/libsystem_network.dylib
0x7fffa40bf000 - 0x7fffa40c8ff3 libsystem_networkextension.dylib (563.30.15) <EB020B0C-7DF0-3EEF-8E3C-15DA3C01D687> /usr/lib/system/libsystem_networkextension.dylib
0x7fffa40c9000 - 0x7fffa40d2ff3 libsystem_notify.dylib (165.20.1) <E7FD3A7C-DD07-36E2-9FA4-7561F9F114DA> /usr/lib/system/libsystem_notify.dylib
0x7fffa40d3000 - 0x7fffa40dbfe7 libsystem_platform.dylib (126.1.2) <3CA06D4E-C00A-36DE-AA65-3A390097D1F6> /usr/lib/system/libsystem_platform.dylib
0x7fffa40dc000 - 0x7fffa40e6ff7 libsystem_pthread.dylib (218.30.1) <C869ED7C-BE29-3532-8E69-3A8DA1447EDC> /usr/lib/system/libsystem_pthread.dylib
0x7fffa40e7000 - 0x7fffa40eaff7 libsystem_sandbox.dylib (592.31.1) <7BBFDF96-293F-3DD9-B3A4-7C168280B441> /usr/lib/system/libsystem_sandbox.dylib
0x7fffa40eb000 - 0x7fffa40ecfff libsystem_secinit.dylib (24) <5C1F1E47-0F7D-3E25-8DEB-D9DB1F902281> /usr/lib/system/libsystem_secinit.dylib
0x7fffa40ed000 - 0x7fffa40f4fff libsystem_symptoms.dylib (532.30.6) <5D990CF5-B58F-39F7-B375-99B4EC62CFBD> /usr/lib/system/libsystem_symptoms.dylib
0x7fffa40f5000 - 0x7fffa4115ff7 libsystem_trace.dylib (518.30.7) <5BD4ECD4-75CA-38EA-AF5C-B481C15955F8> /usr/lib/system/libsystem_trace.dylib
0x7fffa4116000 - 0x7fffa411bffb libunwind.dylib (35.3) <9F7C2AD8-A9A7-3DE4-828D-B0F0F166AAA0> /usr/lib/system/libunwind.dylib
0x7fffa411c000 - 0x7fffa4145ff7 libxpc.dylib (972.30.7) <65E41BB6-EBD5-3D93-B0BE-B190CEE4DD93> /usr/lib/system/libxpc.dylib
@martinklepsch
Copy link
Author

Interestingly this problem somehow seems to be related to Java (of course!) and can be "fixed" by killall -9 java. I have yet to understand the reasons...

@timcharper
Copy link

Woah! I have been experiencing this for a few years off and on! At one point I discovered I could kill stty to resolve, but, that process is nowhere to be seen in the recurrence of the issue I just experienced. killall java did not work because one java process refused to die. And, for further fun, it hung my terminal session and I could not open any new ones.

Fortunately I was able to go in to activity monitor and force kill it

@RyanJarv
Copy link

Had the same stack trace and killing an orphaned nvim seemed to fix it. Guessing the offending program is probably different for everyone, so if anyone comes across this maybe just look for an out of place orphaned terminal app in activity monitor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment