Skip to content

Using with_prototype in a syntax definition can cause ST to use infinite memory #1288

@keith-hall

Description

@keith-hall

Summary

Using with_prototype in a syntax definition can (100% reproduceable) cause ST to immediately start to constantly consume more and more memory, making the OS become unstable a minute afterwards.

Expected behavior

ST wouldn't consume infinite memory, but show a recursion error.

Actual behavior

ST doesn't complain, just locks up while consuming more and more memory.

Steps to reproduce

Create a file called infinite_memory.sublime-syntax in the Packages/User folder with the following contents:

%YAML 1.2

---
# See http://www.sublimetext.com/docs/3/syntax.html
scope: source.example-recursion-out-of-memory-soon
contexts:
  main:
    - match: 'test'
      set: after_test
      with_prototype:
       - match: 'example'
  after_test:
    - match: 'foobar'
      set: main

Then check how much RAM ST is using, and try to interact with ST's UI. Everything is fine until you create a new tab and set the syntax to infinite_memory - check how much RAM ST is using now, and how it is rapidly increasing, and try to interact with ST's UI. (i.e. memory consumption only occurs when a view is open with the dodgy syntax assigned to it.)

Commenting out the set: main line (or with_prototype: line and the - match immediately below it) will enable ST to operate normally. (But you'll have to do it outside ST or destroy your sublime-session or this syntax file first, to get ST to launch again.)

Environment

  • Operating system and version:
    • Windows 7 x64
    • Mac OS (untested)
    • Linux - Ubuntu 16.04 x64
  • Sublime Text:
    • Build 3114, 3119 (but has been there for ages)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions