Sublime Forum

Latest build of Sublime Text 3 on Mac quitting unexpectedly-work is lost

#1

Since yesterday (right around the time I upgraded to the October 1st Build), Sublime Text 3 is quitting. I get the dreaded Sublime Text quit unexpectedly Click Reopen to open the application again. Click Report to see more detailed information and send a report to Apple.

I lose all unsaved work. YIKES! I uninstalled and reinstalled Sublime and am still getting this. I’ve had to switch editors.

Here is a snippet of the report:

Process: Sublime Text [22054]
Path: /Applications/Sublime Text.app/Contents/MacOS/Sublime Text
Identifier: Sublime Text
Version: Build 3211 (3211)
Code Type: X86-64 (Native)
Parent Process: ??? [21998]
Responsible: Sublime Text [22054]
User ID: 501

Date/Time: 2019-10-28 13:38:20.598 -1000
OS Version: Mac OS X 10.14 (18A391)
Report Version: 12

System Integrity Protection: enabled

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

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00007ffeeec4c560
Exception Note: EXC_CORPSE_NOTIFY

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

VM Regions Near 0x7ffeeec4c560:
MALLOC_SMALL 00007fe328800000-00007fe329800000 [ 16.0M] rw-/rwx SM=PRV
–> STACK GUARD 00007ffeeb44d000-00007ffeeec4d000 [ 56.0M] —/rwx SM=NUL stack guard for thread 0
Stack 00007ffeeec4d000-00007ffeef44d000 [ 8192K] rw-/rwx SM=ALI thread 0

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.sublimetext.3 0x0000000100bfdda5 sregex::compile_nfa(sregex::nfa_state*, std::__1::vector<char_set, std::__1::allocator<char_set> > const&, sparse_map*, std::__1::vector<sregex::rvm_instruction,

0 Likes

#2

To add more data: I also attempted to uninstall TabNine yesterday. I also updated a custom syntax highlighter. Not sure which of those 3 things (TabNine, Language, or Update) has caused this problem, or if something else

0 Likes

#3

I lose all unsaved work. YIKES!

This is quite unfortunate. Is Sublime Text crashing on startup, or some time after? Sublime Text makes periodic saves of your session under ~/Library/Application Support/Sublime Text 3/Local/Auto Save Session.sublime_session, could you confirm whether this file gets created when Sublime Text crashes?

From the crash report you posted it looks like it’s crashing when compiling a language syntax. Is there any way you could share the syntax definition so we can reproduce and fix the crash?

1 Like

#4

This is quite unfortunate. Is Sublime Text crashing on startup, or some time after?

It crashes within a few minutes of startup, but not right away. Sometimes it’s within 30 seconds, sometimes it’s a few minutes in I think. I have not been able to figure out exactly what happens before the crash.

could you confirm whether this file gets created when Sublime Text crashes?

I see this file, and my session seems to get restored, but the last minute or so of history seems to be lost.

From the crash report you posted it looks like it’s crashing when compiling a language syntax.

Awesome! Thanks, that narrows it down. I will try removing all my custom language syntaxes and see if can pinpoint the offending one.

Is there any way you could share the syntax definition so we can reproduce and fix the crash?

I have 15 or so so it may take me a bit to find which one causes it. IIRC the one I most recently changed was this: https://gist.github.com/breck7/d9be31b6c31928b9fc02d45f91c7c91a

0 Likes

#5

Ah ok, session restoration seems to be working then. IIRC we save approximately every 30 seconds, so it’s unsurprising that some history gets lost.

Thanks for helping hunt this crash down.

1 Like

#6

Okay, I think I have a reliable repro:

This is the syntax file: https://gist.github.com/breck7/d1d6a4bfc184dc3b06aef62d956ce6ac

The crash seems to only happen when:

  1. This syntax is loaded
  2. A project is opened containing a file(s) that use this syntax
  3. The loading% indicator on the bottom bar hits about 40%, which takes about 8 seconds when loading this project.

I did edit the program that generates this syntax, and looking at it I see there is an “undefined” that shouldn’t be there, which I’ll look into fixing, but my thought is a bad syntax file should not cause a fatal crash? Or am I mistaken there?

For background, the syntax is for a Tree Language called Hakon that compiles to CSS. The syntax file is autogenerated by the jtree Grammar Language library.

0 Likes

#7

A simpler repro:

  1. Install that hakon syntax
  2. Create a new folder and open in sublime.
  3. Touch a file called “anything.hakon”

Instant crash.

0 Likes

#8

Offending lines seem to be:

 'propertyNode':
  - match: '^ *(border-bottom-right-radius\|transition-timing-function\|animation-iteration-count\|animation-timing-function\|border-bottom-left-radius\|border-top-right-radius\|border-top-left-radius\|background-attachment\|background-blend-mode\|text-decoration-color\|text-decoration-style\|overscroll-behavior-x\|-webkit-touch-callout\|animation-play-state\|text-decoration-line\|animation-direction\|animation-fill-mode\|backface-visibility\|background-position\|border-bottom-color\|border-bottom-style\|border-bottom-width\|border-image-outset\|border-image-repeat\|border-image-source\|hanging-punctuation\|list-style-position\|transition-duration\|transition-property\|-webkit-user-select\|animation-duration\|border-image-slice\|border-image-width\|border-right-color\|border-right-style\|border-right-width\|perspective-origin\|-khtml-user-select\|background-origin\|background-repeat\|border-left-color\|border-left-style\|border-left-width\|column-rule-color\|column-rule-style\|column-rule-width\|counter-increment\|page-break-before\|page-break-inside\|background-color\|background-image\|border-top-color\|border-top-style\|border-top-width\|font-size-adjust\|list-style-image\|page-break-after\|transform-origin\|transition-delay\|-ms-touch-action\|-moz-user-select\|animation-delay\|background-clip\|background-size\|border-collapse\|justify-content\|list-style-type\|text-align-last\|text-decoration\|transform-style\|-ms-user-select\|animation-name\|border-spacing\|flex-direction\|letter-spacing\|outline-offset\|padding-bottom\|text-transform\|vertical-align\|align-content\|border-bottom\|border-radius\|counter-reset\|margin-bottom\|outline-color\|outline-style\|outline-width\|padding-right\|text-overflow\|border-color\|border-image\|border-right\|border-style\|border-width\|caption-side\|column-count\|column-width\|font-stretch\|font-variant\|margin-right\|padding-left\|table-layout\|text-justify\|unicode-bidi\|word-spacing\|touch-action\|align-items\|border-left\|column-fill\|column-rule\|column-span\|empty-cells\|flex-shrink\|font-family\|font-weight\|line-height\|margin-left\|padding-top\|perspective\|text-indent\|text-shadow\|white-space\|user-select\|align-self\|background\|border-top\|box-shadow\|box-sizing\|column-gap\|flex-basis\|@font-face\|font-style\|@keyframes\|list-style\|margin-top\|max-height\|min-height\|overflow-x\|overflow-y\|text-align\|transition\|visibility\|word-break\|animation\|direction\|flex-flow\|flex-grow\|flex-wrap\|font-size\|max-width\|min-width\|nav-index\|nav-right\|transform\|word-wrap\|nav-down\|nav-left\|overflow\|position\|tab-size\|columns\|content\|display\|opacity\|outline\|padding\|z-index\|border\|bottom\|cursor\|filter\|height\|margin\|@media\|nav-up\|quotes\|resize\|clear\|color\|float\|order\|right\|width\|clip\|fill\|flex\|font\|left\|all\|top)(?: |$)'
    scope: variable.function.propertyNode
    push:
     - match: ({{propertyKeywordCell}})? ?({{cssValueCell}})?
       captures:
        1: variable.function.propertyKeywordCell
        2: constant.numeric.cssValueCell
     - match: $
       pop: true
0 Likes

#9

If I shorten that long line, and remove some options, it seems to work. So it seems related to line-width?

this works:

  - match: '^ *(border-bottom-right-radius\|transition-timing-function\|animation-iteration-count\|animation-timing-function\|border-bottom-left-radius\|border-top-right-radius\|border-top-left-radius\|background-attachment\|background-blend-mode\|text-decoration-color\|text-decoration-style\|overscroll-behavior-x\|-webkit-touch-callout\|animation-play-state\|text-decoration-line\|animation-direction\|animation-fill-mode\|backface-visibility\|background-position\|border-bottom-color\|border-bottom-style\|border-bottom-width\|border-image-outset\|border-image-repeat\|border-image-source\|hanging-punctuation\|list-style-position\|transition-duration\|transition-property\|-webkit-user-select\|animation-duration\|border-image-slice\|border-image-width\|border-right-color\|border-right-style\|border-right-width\|perspective-origin\|-khtml-user-select\|background-origin\|background-repeat\|border-left-color\|border-left-style\|border-left-width\|column-rule-color\|column-rule-style\|column-rule-width\|counter-increment\|page-break-before\|page-break-inside\|background-color\|background-image\|border-top-color\|border-top-style\|border-top-width\|font-size-adjust\|list-style-image\|page-break-after\|transform-origin\|transition-delay\|-ms-touch-action\|-moz-user-select\|animation-delay\|background-clip\|background-size\|border-collapse\|justify-content\|list-style-type\|text-align-last\|text-decoration\|transform-style\|-ms-user-select\|animation-name\|border-spacing\|flex-direction\|letter-spacing\|outline-offset\|padding-bottom\|text-transform\|vertical-align\|align-content\|border-bottom\|border-radius\|counter-reset\|margin-bottom\|outline-color\|outline-style\|outline-width\|padding-right\|text-overflow\|border-color\|border-image\|border-right\|border-style\|border-width\|caption-side\|column-count\|column-width\|font-stretch\|font-variant\|margin-right\|padding-left\|table-layout\|text-justify\|unicode-bidi\|word-spacing\|touch-action\|align-items\|border-left\|column-fill\|column-rule\|column-span\|empty-cells\|flex-shrink\|font-family\|font-weight\|line-height\|margin-left\|padding-top\|perspective\|text-indent\|text-shadow\|white-space\|user-select\|align-self\|background\|border-top\|box-shadow\|box-sizing\|column-gap\|flex-basis\|@font-face\|font-style\|@keyframes\|list-style\|margin-top\|max-height\|min-height\|overflow-x\|overflow-y\|text-align\|transition\|visibility\|word-break\|animation\|direction\|flex-flow\|flex-grow\|flex-wrap\|font-size\|max-width\|min-width\|nav-index\|nav-right\|transform\|word-wrap\|nav-down\|nav-left\|overflow\|position\|tab-size\|columns\|content)(?: |$)'
0 Likes

#10

Definitely seems related to line width. If I take out a couple of hundred characters, it works fine, regardless of the characters. Or perhaps it’s the number of options in the regex?

0 Likes

#11

Okay, it seems to be related to line width.

This works:

- match: '^ *(a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|@a\|a\|@a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|@a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a\|a)(?: |$)'

This does not:

- match: '^ *(abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|@abcdefghijklmnop\|abcdefghijklmnop\|@abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|@abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop\|abcdefghijklmnop)(?: |$)'
0 Likes

#12

Okay, I think this is the simplest repro I can come up with:

Seems to be simply related to line width of the “match” line. Long lines cause a fatal crash.

0 Likes

#13

If I have 2453 characters in the match regex, it seems to work, but at 2454 characters it crashes. I cannot think of special things about that number or any nearby numbers (https://www.crazy-numbers.com/en/2453), so I am now at a loss.

0 Likes

#14

Okay I just reproduced on a totally different machine on Linux by simply editing the Rust syntax file to turn one of the “match” lines into a very long line > 2453.

0 Likes

#15

Turns out our custom regex engine was causing a stack overflow due to very deep recursion. We’ve got a fix for it in the pipeline (we will fall back to oniguruma in these cases). Although I’m sure you’ve already fixed it, changing all the \| to the desired | in the regex will prevent this issue.

2 Likes

#16

Thanks @bschaaf! I have disable that custom syntax highlighter for now.

FWIW, I’m able to reproduce without any “|” at all.

This line change to the Rust syntax highlighting generates the crash:

0 Likes

#17

Yep, a very long regex with just 'a' is enough to cause the issue.

2 Likes

#18

Out of curiosity, will the regex compatibility syntax test generate a message for syntaxes that fall back for this reason?

1 Like

#19

I had the same question when I was making the fix. Turns out the way it works means it just compiles all the regex, since this regex will fail to compile it will be caught by the regex compatibility test.

2 Likes