Aconex / drakov

Mock Server that implements the API Blueprint specification
MIT License
481 stars 115 forks source link

Crash: Cannot enlarge memory arrays #126

Open mnn opened 8 years ago

mnn commented 8 years ago

When I run drakov -f apiary.apib it crashes after few seconds. I didn't find any way of setting anything memory related from command line.

Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 16777216, (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.
Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 16777216, (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.

C:\Users\xxx\AppData\Roaming\npm\node_modules\drakov\node_modules\drafter.js\emcc\drafter.nomem.js:1
(function (exports, require, module, __filename, __dirname) { var Module={"ready":false,"log":(function(text){console.log("drafter.js: "+text)}),"logErr":(function(text){console.error("drafter.js: "+text)}),"onRuntimeInitialized":(function(){this.ready=true})};var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB;var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function printErr(x){
abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 16777216, (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.") at Error
    at jsStackTrace (C:\Users\xxx\AppData\Roaming\npm\node_modules\drakov\node_modules\drafter.js\emcc\drafter.nomem.js:1:20966)
    at stackTrace (C:\Users\xxx\AppData\Roaming\npm\node_modules\drakov\node_modules\drafter.js\emcc\drafter.nomem.js:1:21149)
    at abort (C:\Users\xxx\AppData\Roaming\npm\node_modules\drakov\node_modules\drafter.js\emcc\drafter.nomem.js:27:29549)
    at enlargeMemory (C:\Users\xxx\AppData\Roaming\npm\node_modules\drakov\node_modules\drafter.js\emcc\drafter.nomem.js:1:21499)
    at Function.Runtime.dynamicAlloc [as alloc] (C:\Users\xxx\AppData\Roaming\npm\node_modules\drakov\node_modules\drafter.js\emcc\drafter.nomem.js:1:6435)
    at _sbrk (C:\Users\xxx\AppData\Roaming\npm\node_modules\drakov\node_modules\drafter.js\emcc\drafter.nomem.js:1:253794)
    at JT (C:\Users\xxx\AppData\Roaming\npm\node_modules\drakov\node_modules\drafter.js\emcc\drafter.nomem.js:6:7016)
    at WR (C:\Users\xxx\AppData\Roaming\npm\node_modules\drakov\node_modules\drafter.js\emcc\drafter.nomem.js:19:36122)
    at FD (C:\Users\xxx\AppData\Roaming\npm\node_modules\drakov\node_modules\drafter.js\emcc\drafter.nomem.js:12:83540)
    at Array.ln (C:\Users\xxx\AppData\Roaming\npm\node_modules\drakov\node_modules\drafter.js\emcc\drafter.nomem.js:7:1993)
If this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.

I "solved" the issue by replacing variable definition in drafter.nomem.js, but I would like to know a better method (one that doesn't break after update), if one exists.

yakovkhalinsky commented 8 years ago

Thanks for the report. I've only tested on Mac OS and Ubuntu runs the builds.

I'll spin up a Windows VM and investigate.

Have you tried splitting your apib file into smaller files?

mnn commented 8 years ago

No, I haven't. Also I'm not sure other tools we use support multiple files, so it's really not a good solution (at least for us).

The input file has approx. 180kB and I was testing it on Windows 10 x64.

yakovkhalinsky commented 8 years ago

Hmm that's a pretty small file.

Windows 10, noted. Which Node.js version are you using?

mnn commented 8 years ago

Oh, my NodeJS is quite old (4.1.1), I'll try updating it and will report back.

mnn commented 8 years ago

Crashes also with NodeJS v5.9.0 (exactly same error).

yakovkhalinsky commented 8 years ago

Thanks @mnn for the update.

Are you able to email me a sanitised version of your file? I would like to test it on other OS's as well as on Win 10.

You can email me yakov at therocketsurgeon dot com

yakovkhalinsky commented 8 years ago

@mnn have you used the previous versions of Drakov?

I have previously had issues compiling Protagonist (Snowcrash) on a Windows machine, mainly due to my ignorance of running C compilers on Windows :)

yakovkhalinsky commented 8 years ago

I'm looking at the possibility of maintaining versions to give user choice as to which parser is used. See #129

mnn commented 8 years ago

I have not. But in Installation instructions there is just npm install ..., I didn't compile anything by hand. gcc seems to be working (at least minimal program compiles just fine). I'm using mingw.

Is there anything else I should check to see if it's working?

yakovkhalinsky commented 8 years ago

if you can try doing npm install drakov@0.2.2 and see if it goes through.

That version uses protagonist which requires some C compilation.

mnn commented 8 years ago

After fixing which version of Python is node-gyp using it compiled. I converted input file to unix line endings and it works without any hacks :smile:.

PS: I'm sure it's the right version (got both installed) - it says in white Drakov 0.2.2.

yakovkhalinsky commented 8 years ago

Yeah it's a pain to install Drakov + Protagonist on Windows.

I would recommend sticking with 0.2.2, until we have another mainline version that has it. Drafter.js doesn't seem to work very well on Windows for now.

yakovkhalinsky commented 8 years ago

@mnn in your previous comment did you mean you had it working with 1.0.0? or just 0.2.2?

mnn commented 8 years ago

@yakovkhalinsky 0.2.2 ran without any hacks, 1.0.0 run also but only after changing variable definition "TOTAL_MEMORY" in drafter.nomem.js to ~10 times higher value. So that apparently is not an ideal solution, it will break with any update.

oklaiss-gpsw commented 8 years ago

I'm finding the same issue here with a 420kb input file. The only solution I have found is splitting the input file into multiple.

yakovkhalinsky commented 8 years ago

Will see if #134 that includes a newer version of Drafter.js improves this issue and report back