textmate / bugs

Bug tracker for TextMate (not its bundles, nor tracking feature requests)
4 stars 0 forks source link

Crash: Caused by specific multi-line mark values #27

Closed koenpunt closed 6 years ago

koenpunt commented 6 years ago

I believe I reported this on the mailing list too, but can't find it anymore, so now I report it here.

The crashlog: https://api.textmate.org/crashes/398794

And a quite a lot before that one.

It happens when I'm editing javascript files, and on save a bundle that tries to handle the (invalid) javascript crashes (I think), which in turn causes TextMate to crash.

While the crash in the bundle shouldn't happen, I can imagine that this shouldn't crash the app as a whole.

infininight commented 6 years ago

Unable to reproduce this locally, I get a report on the error from the code you posted on the mailing list.

I see that you are using a couple plugins, lets disable temporarily to ensure they aren't causing a problem. Move the following directory to your desktop then relaunch TextMate:

/Users/<yourname>/Library/Application Support/TextMate/PlugIns/

See if that corrects the issue. If that doesn't do it, please post a step-by-step guide so I can be sure I'm reproducing the issue correctly.

koenpunt commented 6 years ago

It also happens with the PlugIns directory moved.

For me a invalid piece of javascript (the first case is missing a colon) like the following is enough to get TM to crash:

switch (destination) {
  case 'saved-searches'
    return 'searches';
  case 'add-product':
    return 'add_product';
}

The bundle that is causing the crash is a modified version of JavaScript Eslint: https://github.com/koenpunt/javascript-eslint.tmbundle/tree/js.

The culprit apparently is in the bundle item "Save & Validate with ESLint", which is executing a javascript file with node, which in turn spawns another javascript file.

Weirdly enough it's not crashing on all invalid JS, only some specific cases. For example, this doesn't crash TM:

switch (destination) {
  case 'saved-searches'
    return 'searches';
}

While writing the above, I discovered that the issue is not necessarily with the mentioned bundle, or with javascript per se, since I'm able to reproduce the crash by setting a mark which has multiple lines of content, containing certain characters.

For example, executing the following causes TextMate to crash:

/Applications/TextMate.app/Contents/Resources/mate --clear-mark=warning --clear-mark=error --set-mark='error:[ESLint] Parsing error: Unexpected token, expected ":"

  1 | switch (destination) {
  2 |   case '\''saved-searches'\''
> 3 |     return '\''searches'\'';
    |     ^
  4 |   case '\''add-product'\'':
  5 |     return '\''add_product'\'';
  6 | } (null)' --line=3:5 '/Users/.../switch.js'
infininight commented 6 years ago

OK I can now reproduce the issue. @sorbits I've reduced the test case down to the essential bit:

mate --set-mark='error:
:' --line=3:5 /Users/msheets/test.js

Must be on two lines to cause the issue, thanks @koenpunt !