abe33 / atom-pigments

An Atom package to display colors in project and files.
MIT License
524 stars 68 forks source link

Uncaught RangeError: Maximum call stack size exceeded #19

Closed Blacx closed 9 years ago

Blacx commented 9 years ago

Reproduce:

  1. Open the Command Pallete
  2. Choose Pigments: Find Colors

Atom Version: 0.201.0 System: Microsoft Windows 8 Thrown From: pigments package, v0.3.1

Stack Trace

Uncaught RangeError: Maximum call stack size exceeded

At C:\Users\Whisnu\.atom\packages\pigments\lib\regexes.coffee:0

RangeError: Maximum call stack size exceeded
  at String.replace (native)
  at C:\Users\Whisnu\.atom\packages\pigments\lib\regexes.coffee:23:14
  at Array.map (native)
  at module.exports.createVariableRegExpString (C:\Users\Whisnu\.atom\packages\pigments\lib\regexes.coffee:22:31)
  at module.exports.getRegistry (C:\Users\Whisnu\.atom\packages\pigments\lib\color-expressions.coffee:628:27)
  at ColorParser.module.exports.ColorParser.parse (C:\Users\Whisnu\.atom\packages\pigments\lib\color-parser.coffee:18:16)
  at ColorContext.module.exports.ColorContext.readColor (C:\Users\Whisnu\.atom\packages\pigments\lib\color-context.coffee:41:22)
  at Color.<anonymous> (C:\Users\Whisnu\.atom\packages\pigments\lib\color-expressions.coffee:339:25)
  at ColorExpression.module.exports.ColorExpression.parse (C:\Users\Whisnu\.atom\packages\pigments\lib\color-expression.coffee:15:13)
  at ColorParser.module.exports.ColorParser.parse (C:\Users\Whisnu\.atom\packages\pigments\lib\color-parser.coffee:21:16)

Commands

     -1:09.8.0 command-palette:toggle (atom-text-editor.editor.is-focused)
     -1:08.3.0 editor:consolidate-selections (atom-text-editor.editor.mini.is-focused)
     -1:08.3.0 core:cancel (atom-text-editor.editor.mini.is-focused)
     -0:52.2.0 editor:move-to-first-character-of-line (atom-text-editor.editor.is-focused)
     -0:52 editor:newline (atom-text-editor.editor.is-focused)
     -0:51.7.0 core:move-up (atom-text-editor.editor.is-focused)
  2x -0:30.1.0 core:backspace (atom-text-editor.editor.is-focused)

Config

{
  "core": {
    "disabledPackages": [
      "git-plus"
    ]
  },
  "pigments": {}
}

Installed Packages

# User
highlight-selected, v0.9.3
minimap, v4.9.0
minimap-find-and-replace, v4.2.0
pigments, v0.3.1

# Dev
No dev packages
abe33 commented 9 years ago

Can you give some details about the project in which this error occurred? How large is it? (in term of files, # of variables, etc.).

Blacx commented 9 years ago

Hmm, the good news is the issue is does not happen again. I got atom error package dialog at first time installed the Pigments. The problem does not reoccur after the second action.

The bad news is I'm not sure why this happen. For additional information, I using 3360 colors found in 160 lines (everything was fine after that)

Blacx commented 9 years ago

Oops, it happen again when I change the value : border-color

pigment_rengerror

Sorry.

abe33 commented 9 years ago

I have found articles stating that this kind of errors could occurs in a map when the source array is too big, I guess internally it uses some kind of recursive approach that makes the call stack grows. I can't publish a patch right now as I have some breaking changes pending (some that may allow you to reduce the amount of files used a source by the package), I'll hope to publish it in the course of the week.

Blacx commented 9 years ago

Thanks,

jcblw commented 9 years ago

I also have this issue. I have a file that every time I start typing in the file I get to around two chars and it throws this error.

/Users/me/.atom/packages/pigments/lib/utils.coffee:0

RangeError: Maximum call stack size exceeded
  at String.replace (native)
  at utils.strip (/Users/me/.atom/packages/pigments/lib/utils.coffee:3:23)
  at module.exports.getRegistry (/Users/me/.atom/packages/pigments/lib/color-expressions.coffee:107:40)
  at ColorParser.module.exports.ColorParser.parse (/Users/me/.atom/packages/pigments/lib/color-parser.coffee:18:16)
  at ColorContext.module.exports.ColorContext.readColor (/Users/me/.atom/packages/pigments/lib/color-context.coffee:41:22)
  at Color.<anonymous> (/Users/me/.atom/packages/pigments/lib/color-expressions.coffee:632:27)
  at ColorExpression.module.exports.ColorExpression.parse (/Users/me/.atom/packages/pigments/lib/color-expression.coffee:15:13)
  at ColorParser.module.exports.ColorParser.parse (/Users/me/.atom/packages/pigments/lib/color-parser.coffee:21:16)
  at ColorContext.module.exports.ColorContext.readColor (/Users/me/.atom/packages/pigments/lib/color-context.coffee:41:22)
  at Color.<anonymous> (/Users/me/.atom/packages/pigments/lib/color-expressions.coffee:632:27)
  at ColorExpression.module.exports.ColorExpression.parse (/Users/me/.atom/packages/pigments/lib/color-expression.coffee:15:13)
  at ColorParser.module.exports.ColorParser.parse (/Users/me/.atom/packages/pigments/lib/color-parser.coffee:21:16)
  at ColorContext.module.exports.ColorContext.readColor (/Users/me/.atom/packages/pigments/lib/color-context.coffee:41:22)

I have not seen this error before the recent updates.

kankaristo commented 9 years ago

Happens for me too.

I'm opening my Atom config directory (~/.atom/) in Atom. I have 101 packages installed. Does it go through all of the sub-directories?

kankaristo commented 9 years ago

Sometime earlier (a week ago, or so) I was getting some warning from pigments about some limit of 50 being reached (which I ignored). This was a popup from pigments, not Atom. I can't remember anything more specific, sorry...

abe33 commented 9 years ago

I'm opening my Atom config directory (~/.atom/) in Atom. I have 101 packages installed. Does it go through all of the sub-directories?

Yes, except if their names matches the patterns defined in the ignoredNames setting. It works like a project search, or like the file palette indexing.

Sometime earlier (a week ago, or so) I was getting some warning from pigments about some limit of 50 being reached (which I ignored). This was a popup from pigments, not Atom. I can't remember anything more specific, sorry.

Yes, it was a failed attempt to reduce the load by warning, but it was clearly suboptimal (see #23). I plan to get rid of that as soon as I have finish my work on optimizing the handling/filtering of variables.

As for the maximum stack size exceeded error, the fact that the stack place it in String.replace is quite disturbing. And this is a replace call that is done in utils.strip which basically just remove all extra white spaces when building the regular expressions used to detect variables and colors. I've seen seen here and there some people linking this kind of error to node hitting the limit for parallel processes, what do you get when running ulimit -u in a terminal (for unix users, for windows I don't know the corresponding command).

Globegitter commented 9 years ago

Running into this error as well now. Here is my stacktrace: https://gist.github.com/Globegitter/c739966fbdd78dc2cea2

kankaristo commented 9 years ago

I've seen seen here and there some people linking this kind of error to node hitting the limit for parallel processes, what do you get when running ulimit -u in a terminal

Maximum paraller processes (soft and hard limits are the same):

$ ulimit -u
127229

Maximum stack size (hard limit is unlimited):

$ ulimit -s
8192
abe33 commented 9 years ago

Thanks for the feedbacks

@kankaristo I can exclude a process issue, your limits are really high (ulimit -u gives me 709).

@Globegitter your stack trace tell me that it loops in the handler for grayscale() expressions, do you happen to use it in oneof your files? And would be kind enough to share that file with me so that I can investigate what's going on?

luisrudge commented 9 years ago

:+1: I'm having this too

luisrudge commented 9 years ago

I'm loading bootstrap's variables file and atom becomes unusable. It freezes every few seconds

abe33 commented 9 years ago

@luisrudge let me know if latest version (0.5.0) helps things for you. I've tried it on the bootstrap repo and the performance was slightly better.

However I'm still unable to reproduce the range error, I'm sorry guys but I'll really have to rely on you to help me on this. The more details the sooner I'll find the root cause.

kankaristo commented 9 years ago

@abe33: I can't speak for the others, but 0.5.0 seems to fix this for me. Thanks! :+1:

luisrudge commented 9 years ago

yep. Better for me too!

abe33 commented 9 years ago

Glad to hear that, I'll keep this open open for a bit, in the case it happens again. Let me know if you get it again.

teliosdev commented 9 years ago

I got this one time, and then three more times trying to reproduce it. I ran the command Pigments: Find Colors.

Atom Version: 0.209.0 System: Mac OS X 10.10.3 Thrown From: pigments package, v0.6.0

Stack Trace

Uncaught RangeError: Maximum call stack size exceeded

At /Users/medcat/.atom/packages/pigments/lib/utils.coffee:0

RangeError: Maximum call stack size exceeded
  at String.replace (native)
  at utils.strip (/Users/medcat/.atom/packages/pigments/lib/utils.coffee:3:23)
  at module.exports.getRegistry (/Users/medcat/.atom/packages/pigments/lib/color-expressions.coffee:107:40)
  at ColorParser.module.exports.ColorParser.parse (/Users/medcat/.atom/packages/pigments/lib/color-parser.coffee:20:16)
  at ColorContext.module.exports.ColorContext.readColor (/Users/medcat/.atom/packages/pigments/lib/color-context.coffee:48:22)
  at Color.<anonymous> (/Users/medcat/.atom/packages/pigments/lib/color-expressions.coffee:543:25)
  at ColorExpression.module.exports.ColorExpression.parse (/Users/medcat/.atom/packages/pigments/lib/color-expression.coffee:15:13)
  at ColorParser.module.exports.ColorParser.parse (/Users/medcat/.atom/packages/pigments/lib/color-parser.coffee:24:17)
// truncated most of the stack...
  at ColorContext.module.exports.ColorContext.readColor (/Users/medcat/.atom/packages/pigments/lib/color-context.coffee:48:22)
  at Color.<anonymous> (/Users/medcat/.atom/packages/pigments/lib/color-expressions.coffee:543:25)
  at ColorExpression.module.exports.ColorExpression.parse (/Users/medcat/.atom/packages/pigments/lib/color-expression.coffee:15:13)
  at ColorParser.module.exports.ColorParser.parse (/Users/medcat/.atom/packages/pigments/lib/color-parser.coffee:24:17)
  at ColorContext.module.exports.ColorContext.readColor (/Users/medcat/.atom/packages/pigments/lib/color-context.coffee:48:22)
  at Color.<anonymous> (/Users/medcat/.atom/packages/pigments/lib/color-expressions.coffee:543:25)
  at ColorExpression.module.exports.ColorExpression.parse (/Users/medcat/.atom/packages/pigments/lib/color-expression.coffee:15:13)
  at ColorParser.module.exports.ColorParser.parse (/Users/medcat/.atom/packages/pigments/lib/color-parser.coffee:24:17)
  at /Users/medcat/.atom/packages/pigments/lib/color-search.coffee:44:32
  at searchOptions.didMatch (/Applications/Atom.app/Contents/Resources/app.asar/src/workspace.js:850:22)
  at Task.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/emissary/lib/emitter.js:118:15)
  at ChildProcess.<anonymous> (/Applications/Atom.app/Contents/Resources/app.asar/src/task.js:81:31)
  at emitTwo (events.js:87:13)
  at ChildProcess.emit (events.js:169:7)
  at handleMessage (child_process.js:306:10)
  at Pipe.channel.onread (child_process.js:334:11)

Commands

     -2:47.1.0 pigments:reload (atom-text-editor.editor)
     -2:10.1.0 command-palette:toggle (atom-text-editor.editor.is-focused)
  4x -2:08.3.0 core:backspace (atom-text-editor.editor.mini.is-focused)
  2x -2:06.1.0 core:move-down (atom-text-editor.editor.mini.is-focused)
     -2:05.1.0 core:move-up (atom-text-editor.editor.mini.is-focused)
     -2:04.6.0 core:move-down (atom-text-editor.editor.mini.is-focused)
     -2:04.3.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -2:04.3.0 pigments:show-palette (atom-text-editor.editor)
     -2:00.5.0 command-palette:toggle (atom-text-editor.editor.is-focused)
     -1:58.9.0 core:move-down (atom-text-editor.editor.mini.is-focused)
     -1:58.6.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -1:58.6.0 pigments:find-colors (atom-text-editor.editor)
     -0:10.1.0 command-palette:toggle (atom-text-editor.editor.is-focused)
  3x -0:07.7.0 core:move-up (atom-text-editor.editor.mini.is-focused)
     -0:06.8.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -0:06.8.0 pigments:find-colors (atom-text-editor.editor)

Config

{
  "core": {
    "themes": [
      "isotope-ui",
      "monokai"
    ],
    "disabledPackages": [
      "atom-color-highlight",
      "minimap-color-highlight",
      "build"
    ],
    "projectHome": "/Users/medcat/Projects"
  },
  "pigments": {}
}

Installed Packages

# User
docblockr, v0.7.2
emmet, v2.3.10
fonts, v0.4.2
isotope-ui, v2.4.0
language-antelope, v0.0.2
language-curly, v0.0.2
language-latex, v0.6.1
language-lua, v0.9.3
minimap, v4.10.0
minimap-pigments, v0.1.1
monokai, v0.14.0
pigments, v0.6.0
project-palette-finder, v2.4.17
set-syntax, v0.3.0
travis-ci-status, v0.15.1

# Dev
No dev packages
crucialfelix commented 9 years ago

I just got it on 0.6.0

  1. Just opened Atom with a small project
  2. Failed to activate package

The project is small, only a few jade and markdown files open. There are a few css files, some scss. Bourbon and Neat are in the src folder so that would make 80 total scss files.

edit: I had pigments settings to ignore components, but not bower_components. In this project there are a lot of things in there. I just added to ignore that as well and now pigments has no problem activating.

Atom Version: 0.209.0 System: Mac OS X 10.10.2 Thrown From: pigments package, v0.6.0

Stack Trace

Failed to activate the pigments package

At Maximum call stack size exceeded

RangeError: Maximum call stack size exceeded
    at String.replace (native)
    at utils.strip (/Users/crucial/.atom/packages/pigments/lib/utils.coffee:6:18)
    at module.exports.getRegistry (/Users/crucial/.atom/packages/pigments/lib/color-expressions.coffee:85:44)
    at ColorParser.module.exports.ColorParser.parse (/Users/crucial/.atom/packages/pigments/lib/color-parser.coffee:29:18)
    at ColorContext.module.exports.ColorContext.readColor (/Users/crucial/.atom/packages/pigments/lib/color-context.coffee:92:28)
    at Color.<anonymous> (/Users/crucial/.atom/packages/pigments/lib/color-expressions.coffee:311:29)
    at ColorExpression.module.exports.ColorExpression.parse (/Users/crucial/.atom/packages/pigments/lib/color-expression.coffee:23:19)
    at ColorParser.module.exports.ColorParser.parse (/Users/crucial/.atom/packages/pigments/lib/color-parser.coffee:34:19)
    at ColorContext.module.exports.ColorContext.readColor (/Users/crucial/.atom/packages/pigments/lib/color-context.coffee:92:28)
    at Color.<anonymous> (/Users/crucial/.atom/packages/pigments/lib/color-expressions.coffee:311:29)
    at ColorExpression.module.exports.ColorExpression.parse (/Users/crucial/.atom/packages/pigments/lib/color-expression.coffee:23:19)
    at ColorParser.module.exports.ColorParser.parse (/Users/crucial/.atom/packages/pigments/lib/color-parser.coffee:34:19)
    at ColorContext.module.exports.ColorContext.readColor (/Users/crucial/.atom/packages/pigments/lib/color-context.coffee:92:28)
    at Color.<anonymous> (/Users/crucial/.atom/packages/pigments/lib/color-expressions.coffee:311:29)
    at ColorExpression.module.exports.ColorExpression.parse (/Users/crucial/.atom/packages/pigments/lib/color-expression.coffee:23:19)
    at ColorParser.module.exports.ColorParser.parse (/Users/crucial/.atom/packages/pigments/lib/color-parser.coffee:34:19)

Commands

Config

{
  "core": {
    "ignoredNames": [
      "*.pyc",
      ".DS_Store"
    ],
    "followSymlinks": true,
    "disabledPackages": [
      "cute-cursor",
      "language-go",
      "language-java",
      "syntax-settings",
      "term",
      "language-supercollider",
      "linter-rst",
      "rst-preview",
      "rst-preview",
      "linter",
      "atom-runner",
      "make-runner",
      "ide-haskell",
      "remote-edit",
      "atomatigit",
      "minimap",
      "autocomplete-paths",
      "minimap-highlight-selected",
      "tabs-to-spaces",
      "atomic-emacs",
      "git-log",
      "autoflow",
      "autosave",
      "background-tips",
      "block-travel",
      "dash",
      "easy-motion",
      "gist-it",
      "git-blame",
      "git-difftool",
      "git-plus",
      "trailing-spaces",
      "project-colorize",
      "file-icons",
      "term2",
      "web-view",
      "atom-terminal",
      "command-logger",
      "css-color-highlighting",
      "editor-stats",
      "selection-count",
      "fancy-new-file",
      "language-clojure",
      "language-docker",
      "minimap-find-and-replace",
      "mobile-preview",
      "my-package",
      "sourcegraph-atom",
      "org",
      "paredit",
      "autocomplete",
      "jumpy",
      "atom-color-highlight",
      "last-cursor-position",
      "angularjs",
      "angularjs-snippets",
      "todo-show",
      "autocomplete-jedi",
      "bezier-curve-editor",
      "coffee-lint",
      "python-jedi",
      "org-mode",
      "highlight-selected",
      "node-resolver",
      "next-occurrence",
      "linter-scss-lint",
      "linter-coffeelint",
      "Atom-Syntax-highlighting-for-Sass",
      "grunt-runner",
      "typewriter-sounds",
      "ide-flow",
      "regex-railroad-diagram",
      "symbols-view"
    ],
    "destroyEmptyPanes": false,
    "themes": [
      "one-dark-ui",
      "railscast-theme"
    ]
  },
  "pigments": {
    "sortPaletteColors": "by color",
    "ignoredNames": [
      "node_modules/*",
      "components/*",
      "nsclasses/nestseekerswww/*"
    ],
    "mergeColorDuplicates": true,
    "sourceNames": [
      "**/*.scss"
    ]
  }
}

Installed Packages

# User
atom-ctags, v4.1.2
atom-django, v0.3.0
atom-ternjs, v0.6.4
autoclose-html, v0.18.0
autocomplete-plus-python-jedi, v0.3.6
autocomplete-python, v0.4.2
color-picker, v2.0.4
django-templates, v0.5.0
editorconfig, v1.0.0
emmet, v2.3.10
javascript-snippets, v1.0.0
language-crontab, v0.1.0
language-jade, v0.4.0
language-restructuredtext, v0.6.0
linter-csslint, v0.0.13
linter-jscs, v1.12.0
linter-jshint, v0.1.6
linter-jsxhint, v0.1.2
linter-pep8, v0.2.0
linter-pylint, v0.2.2
pain-split, v1.4.0
pigments, v0.6.0
project-manager, v1.15.10
railscast-theme, v0.3.0
react, v0.12.0
set-syntax, v0.3.0
tree-view-git-status, v0.1.1
vim-mode, v0.53.0
zentabs, v0.8.4

# Dev
No dev packages
abe33 commented 9 years ago

Thanks to @crucialfelix I was able to find the cause of this infinite recursion. Bourbon (and probably many other) use tricks like $border: grayscale($border) and that was making fail the parsing of the value.

crucialfelix commented 9 years ago

Nice one, thanks for solving it Cédric !

On Mon, Jun 15, 2015 at 12:05 AM Cédric Néhémie notifications@github.com wrote:

Thanks to @crucialfelix https://github.com/crucialfelix I was able to find the cause of this infinite recursion. Bourbon (and probably many other) use tricks like $border: grayscale($border) and that was making fail the parsing of the value.

— Reply to this email directly or view it on GitHub https://github.com/abe33/atom-pigments/issues/19#issuecomment-111879154.