PrimeEuler / mib.js

Compile management information base conversion to javascript
14 stars 11 forks source link

Max stack size exceeded in OID function recursion #3

Open kmoughon opened 6 years ago

kmoughon commented 6 years ago

While trying to parse several MIBs I run into max stack size. Here is the output: PS D:\MIBParsingTests\mib.js-master\mib.js-master> node .\mib2json.js Loading modules... Compiling modules... D:\MIBParsingTests\mib.js-master\mib.js-master\lib\mib.js:734 OID: function (OBJECT_IDENTIFIER, ID, ObjectName, OD, callback) { ^

RangeError: Maximum call stack size exceeded at Object.OID (D:\MIBParsingTests\mib.js-master\mib.js-master\lib\mib.js:734:23) at Object.OID (D:\MIBParsingTests\mib.js-master\mib.js-master\lib\mib.js:758:30) at Object.OID (D:\MIBParsingTests\mib.js-master\mib.js-master\lib\mib.js:758:30) at Object.OID (D:\MIBParsingTests\mib.js-master\mib.js-master\lib\mib.js:758:30) at Object.OID (D:\MIBParsingTests\mib.js-master\mib.js-master\lib\mib.js:758:30) at Object.OID (D:\MIBParsingTests\mib.js-master\mib.js-master\lib\mib.js:758:30) at Object.OID (D:\MIBParsingTests\mib.js-master\mib.js-master\lib\mib.js:758:30) at Object.OID (D:\MIBParsingTests\mib.js-master\mib.js-master\lib\mib.js:758:30) at Object.OID (D:\MIBParsingTests\mib.js-master\mib.js-master\lib\mib.js:758:30) at Object.OID (D:\MIBParsingTests\mib.js-master\mib.js-master\lib\mib.js:758:30)

As you can see the OID function is the majority of the stack. I tried some suggestions found on stack overflow using things like setTimeout() and nextTick() to clear the stack but then ran into scope binding issues that i couldn't fix with simple binds. The MIBs i have parse fine in other programs. Any thoughts?

PrimeEuler commented 6 years ago

This project has been replaced by: https://github.com/PrimeEuler/asn2json.

There is an example of SMI (MIB) parsing here: https://github.com/PrimeEuler/asn2json/blob/master/SMI/smi2json.js

Let me know if you have the same issues.

kmoughon commented 6 years ago

Thanks I gave the library a try and it worked in terms of successfully parsing to JSON. One thing this library did was include the full OID in the output of each object, which in my use case is extremely valuable. Is there an option with the new library or a way to derive the full OID from the output?

PrimeEuler commented 6 years ago

Absolutly. I've separated the display format and searching capabilities into a mib browser module thats in the works. I could include a utils module in the smi2json project for this capability if you'd like to put in a request.