wkx icon indicating copy to clipboard operation
wkx copied to clipboard

Stack size error when parsing a larger WKT input string

Open wouterbeek opened this issue 3 years ago • 1 comments

Observed

I observe the following error message when parsing the attached longer WKT input string:

/home/wouter/tmp/geo-test/node_modules/wkx/lib/multipolygon.js:62
        exteriorRing.push.apply(exteriorRing, value.matchCoordinates(options));
                          ^

RangeError: Maximum call stack size exceeded
    at Function.MultiPolygon._parseWkt (/home/wouter/tmp/geo-test/node_modules/wkx/lib/multipolygon.js:62:27)
    at Function.Geometry._parseWkt (/home/wouter/tmp/geo-test/node_modules/wkx/lib/geometry.js:67:33)
    at Function.Geometry.parse (/home/wouter/tmp/geo-test/node_modules/wkx/lib/geometry.js:26:25)
    at Object.<anonymous> (/home/wouter/tmp/geo-test/mwe.js:3:14)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47

Expected

The WKT input string to parse correctly, or a syntax error in case the input string is malformed, but not a memory/allocation-related error.

Steps to reproduce

  1. Download the attached file mwe.txt that contains the input string. (The string is too large to comfortably share as inline text.)
  2. Run the following script and observe the error communitated above:
const fs = require('fs')
const wkx = require('wkx')
const input = fs.readFileSync('mwe.txt', 'utf8')
wkx.Geometry.parse(input)

mwe.txt

wouterbeek avatar Aug 21 '22 12:08 wouterbeek

I'm encountering this issue too.

kalda341 avatar Jul 06 '23 04:07 kalda341