You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Terminal.app crashing: Can I disable callbacks?

Five times in the last 48 hours, Terminal.app "quit unexpectedly". The Terminal_datestamp.crash files show

EXC_BAD_ACCESS (SIGSEGV) KERN_INVALID_ADDRESS at 0x0000000000000000

with a call stack that always includes:

com.apple.Terminal 0x000000010530bc94 0x105295000 + 486548 com.apple.Foundation 0x00007fff972ac5df __NSFireTimer + 83 com.apple.CoreFoundation 0x00007fff95837d74 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20 com.apple.CoreFoundation 0x00007fff958379ff __CFRunLoopDoTimer + 1071 com.apple.CoreFoundation 0x00007fff9583755a __CFRunLoopDoTimers + 298 com.apple.CoreFoundation 0x00007fff9582ef81 __CFRunLoopRun + 2065

User impact

I cannot use the system: must find solution, even if the cost is to wipe disk and install previous OS (El Capitan).

The primary question

(q1) Is there some new feature of Sierra that integrates Terminal with other apps that can be turned off, perhaps a setting to disable callbacks?

Secondary questions

  • (q2) Can I potentially run a copy of the Terminal.app from a previous version of Mac OS X? Prior to my new laptop (and Sierra) these crashes never happened.
  • (q3) What additional detail would be useful, and how can I collect it?

    I am familiar with Unix application development, but not for Mac OS X. I am happy to collect additional detail by turning on debug tools, traces, event collectors, etc. but would need pointers to get started. Xcode is available, but I would be a beginner with it.

System summary

  • New MacBook Pro (Retina, 15-inch, Mid 2015).
    • Arrived 6 days ago.
    • (Yes, I intentionally bought a brand-new instance of the previous model.)
    • Surprisingly, it arrived with Sierra. It presently has 10.12.1
    • Xcode installed
    • GCC 6.2.0 available, built locally.
  • Previous history brought in by Migration Assistant
  • Not tried (yet, anyway)
    • I have briefly visited safe mode but have not stayed there. I do not know whether there would be crashes of Terminal.app if I spent all day in safe mode
    • I do not know whether there would be crashes if I created a fresh, different user account.
  • Tentative rule-outs:
    • Malware, adware, etc are reasonably unlikely given the usage pattern for this work system: firewalls in sw and hw, no visiting of dicey websites, primary application used all day long is vim.
    • However, if Terminal is now integrated with the world wide web then I suppose anything is possible.

MacBook Pro with Retina display, macOS Sierra (10.12.1)

Posted on Dec 8, 2016 7:06 AM

Reply
Question marked as Top-ranking reply

Posted on Feb 19, 2017 4:53 AM

Heya!


This problem's been bugging me as well and with the information from this thread I narrowed it down to the following:


Stuart's test case can be simplified to the following:

  1. Open vim an enter three lines of arbitrary text such as this:
    a
    a aaaaaaaaaaaaaaaaa
    a
    - First and third line just have to be present - no idea why.
    - The second line needs to have a space as the second character and wrap exactly one character to the next line.
    User uploaded file
  2. Delete the first character of the second line by pressing x so that now the line starts with a space and the last character of the line moves to the last column of the terminal.
    User uploaded file
  3. Wait about a second and Terminal.app will crash.


This suggests that Terminal.app has for some reason problems with lines that start with a space and end on the last column of the terminal.


It also only seems to relate with redrawing of the screen because I was not able to reproduce it with echo commands from the command line and I have only ever seen it with full-screen terminal applications like vim and screen, running both locally and remotely.


I had a suspicion it was related to the alternate screen which both vim and screen use by default. I was able to rule that out by setting TERM=vt100 to disable use of the alternate screen and still being able to trigger the crash as described above.


The problem seems to have been introduced with Terminal.app 387 of the 10.12.1 update. I extracted version 377 from my recovery partition (also present in the original 10.12.0 installer) which copes fine with above test case.


The obvious difference between both versions when diff'ing output of the strings command on both executables it the additon of Touchbar functionality mostly relating to man page interaction. I was not able to find any knob to disable this functionality to further narrow down the cause.


Thanks everyone for their research, providing a simple and reproducible test case and the workaround of going back to version 377 for now,

Michael

193 replies

Mar 27, 2017 11:54 AM in response to john henning

Just installed 10.12.4 (hot off the presses) - and it seems to be fixed. Tested using the crashTerminal.applescript posted earlier in the thread.


I'm going to go back to my "regularly scheduled programming" - that is - normal usage, SSHed into remote Linux machine with screen and running /editing very long command lines. If I get any crashes from that I will post an update.


Thanks to everyone in this thread and their hard work narrowing this down and providing test scripts / hard data.

Mar 28, 2017 11:26 AM in response to gpolitis

Hi gpolitis, does your stack backtrace look similar to the others posted here which were associated with the vi-triggered crashes? If you can supply a simple, reproducible example I will test on my system. If there is a remaining subset of Terminal redraw problems that are still causing crashes it will obviously be to the benefit of all here to get them fixed.

Mar 28, 2017 1:05 PM in response to vom

Well I just had Terminal crash again. I didn't think to save the trace, but I was SSH'ed into a Linux box using screen with a super long command line. So while the test case applescript doesn't seem to trigger it anymore, unfortunately I wouldn't call it fixed either.

Mar 28, 2017 1:29 PM in response to vom

If someone can give me a reproducible crash recipe using ssh/screen I will try to keep my Apple support case on this issue open. I am *not* a screen user, though, so I need some serious detail, i.e., every keystroke you can recall. I tried doing some screen experimentation myself a few weeks ago after reading others' reports on those crashes but could not make Terminal crash.


I think it's important to run this down to the bitter end, otherwise I'll be using vi in some different set of peculiar circumstances a few weeks/months from now and it will crash there, too.

Mar 30, 2017 8:00 AM in response to RogerDavis

Here's one in 10.12.3 (I'm waiting for the University to put out 10.12.4 in their Managed Updates).


Here's my sequence. I found that commenting out the crashy line still makes it crash so I could take out some work-specific info and make it not do anything, so here ya go.

1) Set up a terminal in Terminal.app preferences to "ssh {Some redhat system}, size 80x25 (don't know if that matters).

2) Open the terminal to the Red Hat system

3) screen -R myscreen # now you're in a screen session called "myscreen"

4) $ set -o emacs # allows you to edit a command line with emacs keys. Maybe vi-style editing works

# but I had this in emacs

4) Issue this sequence of 3 commands (first one is one long line; I separated the lines by a single blank line here but I had them one after the other:


#while true; do date>>/tmp/wget.log; wget --no-check-certificate --no-verbose --timeout=30 https://www.example.com 2>> /tmp/wget.log ; /bin/rm index.html*; sleep 30; done

view /tmp/wget.log

rm /tmp/wget.log

5) Up and down arrow through your command history to line #1, and try arrowing back and forth through it, maybe use CTRL+A to go to the start of the line (the way my screen is set, CTRL+A is an escape key so I have to issue CTRL+A CTRL+A, then CTRL+E to go to end of the line). Sometimes that will crash the line, other times it won't (like now as I'm typing this and trying it out, it's failing to crash after being reliably crashing the last few times I tried it and re-entered my screen session ... and now just after I said it failed, I did a single up-arrow to a command and it crashed). It seems to take a long line in your command history to crash it. *sigh* I wish this were as easy as the previous always-crash vi example.

6) If it crashes and restores things, re-login and go to "screen -r myscreen" to get back to it.

7) (for a non-screen user, just how to get out of this if you're experimenting) When you're done to destroy your screen, keep typing "exit" -- either it will finally say "screen is exiting," or you'll get a prompt to keep or destroy the screen and just press the right key to destroy it.

Breaking news -- I *think* it happens way more often after I've let the screen session sit for a few minutes. I had been trying to get it to crash again without success, and then I had left it alone for 5 minutes and up-arrowed past the long line. It briefly showed the line above it for a bare fraction of a second and crashed; I believe that's often the case.

Mar 30, 2017 8:01 AM in response to rkcarter

(can't find a way to delete this, just edit -- I added the same info to my original reply. So ignore, redundant).


More now... I *think* it happens way more often if you leave it sit for a while. I was trying several times to crash it, and nothing, and just now I had it sitting for about 5 minutes, and up-arrowed past that long line and it briefly showed the line above it in the history and then crashed. I am starting to think I've seen that more commonly when I come back to something after a while.

Mar 30, 2017 11:30 AM in response to rkcarter

I heard news the newest sierra found issues with the terminal crashing when (vt101?) escape sequences that were not handled were input. HOwever i'm unsure the news is not released by people who "manage viim for apple".


I THINK IT'S GREAT APPLE HAS MADE VI + TERMINAL.APP A PART OF IT'S MORE STABLE ITEMS IN IT'S RELEASES.


I'm glad your thing worked however: as I said before. Vim crashes in linux but Elvis does not. And it began doing so in the year 2007 or so and - not before. It's not xterm doing it either (the xterm the ncurses author wrote).


it's was never true (for GNU/linux) you can't crash terminal emulators with crazy sequences! what was true is that apps that fed garbage to "well known terminals like xterm" were banned from distribution or marked with warnings and not the default.


just try this: cat /usr/bin/bash >> /dev/tty1 and see if it doesn't crash even a text terminal, or cause bad problems with xterm.


the fact with vim is you cannot trust it. I beleive it was specifically hacked to send unsupported ESC sequences to terminals to cause either forced upgrade, dis-use of X-Windows, and etc.


there's ALLOT of malware and some of it is terribly "HIGH BROW". that doesn't mean there isn't simple errors in vim or Terminal.app that feed garbage or crash on input that was thought to be stable.


HOWEVER as i said. Vim since the 2000's has had a long list of bugs and complaints as to working with unix-like terminal support terminals. this likely began with international support + altered font support. the difference is that they (vim) broke what had been working and made the broken mode of operation the default mode of operation.


say all you want it's not malware. I know it is. for every Vim there are A THOUSAND MORE apps they have done this too. I'm swimming in the blame game excuses. I can hardly use my new PC without continual issues. the reason why: lack of accountability of who is putting in code in which OS (anonymous uploaders!!!). and high brow white collar crime.

Mar 30, 2017 3:24 PM in response to RogerDavis

Still happening in 10.12.4. I think I have found another consideration to make it happen (change focus away from Terminal.app, wait 2+ minutes -- well, that's how long I waited, come back and start arrowing around). So to recap (and fix a slight typo -- if "screen" is using CTRL+A as its escape character, use CTRL+A A to go to start of line -- not CTRL+A CTRL+A):


Here's my sequence. I found that commenting out the crashy line still makes it crash so I could take out some work-specific info and make it not do anything, so here ya go.

1) Set up a terminal in Terminal.app preferences to "ssh {Some redhat system}, size 80x25 (don't know if that matters).

2) Open the terminal to the Red Hat system

3) screen -R myscreen # now you're in a screen session called "myscreen"

4) $ set -o emacs # allows you to edit a command line with emacs keys. Maybe vi-style editing works

# but I had this in emacs

4) Issue this sequence of 3 commands (first one is one long line; I separated the lines by a single blank line here but I had them one after the other:


#while true; do date>>/tmp/wget.log; wget --no-check-certificate --no-verbose --timeout=30 https://www.example.com 2>> /tmp/wget.log ; /bin/rm index.html*; sleep 30; done

view /tmp/wget.log

rm /tmp/wget.log

5) Up and down arrow through your command history to line #1, and try arrowing back and forth through it, maybe use CTRL+A to go to the start of the line (the way my screen is set, CTRL+A is an escape key so I have to issue CTRL+A A, then CTRL+E to go to end of the line). If you just got here and played with things, it may not crash. But hang on for the next two new steps:

NEW STEP 5a) Change focus to another app -- Chrome or Mail.app seem to work for this.

NEW STEP 5b) Return focus to Terminal.app and up-arrow through your command history. I think this is pretty reliable to crash it now.

6) If it crashes and tells you your terminal has been restored, re-login and go to "screen -r myscreen" to get back to it. Sometimes then going through the history will re-crash it quickly then.

7) (for a non-screen user, just how to get out of this if you're experimenting) When you're done to destroy your screen, keep typing "exit" -- either it will finally say "screen is exiting," or you'll get a prompt to keep or destroy the screen and just press the right key to destroy it.

Mar 30, 2017 3:23 PM in response to rkcarter

When it crashes in 10.12.4, the part which looks like what others have posted here is:

8 com.apple.Terminal 0x000000010cde6c0c 0x10cd70000 + 486412

9 com.apple.Foundation 0x00007fffa1295f3f __NSFireTimer + 83

10 com.apple.CoreFoundation 0x00007fff9f80cd04 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20

11 com.apple.CoreFoundation 0x00007fff9f80c98f __CFRunLoopDoTimer + 1071

12 com.apple.CoreFoundation 0x00007fff9f80c4ea __CFRunLoopDoTimers + 298

13 com.apple.CoreFoundation 0x00007fff9f803c31 __CFRunLoopRun + 2065

Mar 30, 2017 5:00 PM in response to rkcarter

Verified on my system rkcarter, thanks! (I also had to <CTRL>-Z and then 'bg' after entering the while-loop command line to return control to my ssh shell so I could enter the 'view' and 'rm' commands.)


The crash also occurs if I ssh into another Mac (ElCap), so the RedHat remote platform is irrelevant. When I ssh into another Mac your while loop generates a SIGSEGV fault of its own (within the loop, so it keeps running anyway), but no matter -- after I enter your 'view' and 'rm' commands and then up-/down-arrow for a bit, Terminal crashes.


I will try to keep the heat on with my support case contact using this example, thanks!


And, for all other followers of this thread, it would be very useful to know if anyone experiences any further vi-related crashes (as opposed to screen-related) in 10.12.4 or later. I wonder if Apple 'fixed' this bug by tweaking vi to stop sending whatever command sequence was making Terminal barf. If so, it's not a real fix if app X (as opposed to vi) continues to send the same sequence.

Mar 30, 2017 7:58 PM in response to RogerDavis

RogerDavis, sounds like you didn't catch that the "#" was a comment character in front of the 'while' command (running it was irrelevant -- coming across it with up arrows is relevant)... actually there could've been a "#" in front of all the commands I bet. It had started with a real command and I figured out that it was probably just the length of the command itself.

Terminal.app crashing: Can I disable callbacks?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.