New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Max call stack size exceeded under io.js #5
Comments
This is odd as no recursiveness is going on there (except if applying the regex itself is). |
Here's my isolation code so far: var fs = require('fs')
var convert = require('convert-source-map')
var source = fs.readFileSync('./source.js', 'utf8')
var patt1 = /^[ \t]*(?:\/\/|\/\*)[@#][ \t]+sourceMappingURL=data:(?:application|text)\/json;base64,(.+)(?:\*\/)?/mg
var patt2 = convert.commentRegex
try {
var m = source.match(patt1)
console.log('success with patt1')
} catch(ex) {
console.log('fail with patt1')
console.log(ex.message)
}
try {
var m = source.match(patt2)
console.log('success with patt2')
} catch(ex) {
console.log('fail with patt2')
console.log(ex.message)
} ...which outputs: $ node test.js
success with patt1
fail with patt2
Maximum call stack size exceeded What's weird is that |
I filed a bug on V8, however they pointed out this regex uses backtracking, and that a range error is expected behavior when running a backtracking regex against big strings. Which is an argument against using regex to extract the source map comment in the first place, especially since concatenated source files (eg produced by browserify) are typically huge. For example, maybe find |
issue reported: thlorenz/mold-source-map#5 If this change work you should be able to process a source string with the limit of the process memory and not the regexp stack. I tested it with ~1gb of string. please test cc: @greim
I had commented out |
Weird. If I comment out some seemingly completely unrelated code, my build works just fine. The unrelated code is doing markdown parsing using https://www.npmjs.com/package/marked Which incidentally is very regex-driven. |
@greim that is to be expected as marked is using regex to parse. In the meantime I'll upgraded convert-source-map and pushed a new patch release, but since the csm fix was also a patch you should already have gotten that fix in msm automatically. Closing since issue is resolved from mold-source-map POV. |
I only see this on io.js, not on node 0.11 or o.12.
The text was updated successfully, but these errors were encountered: