CesiumGS / obj2gltf

Convert OBJ assets to glTF
Apache License 2.0
1.67k stars 302 forks source link

Normal index 303 is out of bounds -causing socket hung and memory issue #287

Open PatidarVk opened 1 year ago

PatidarVk commented 1 year ago

Error at new RuntimeError (D:\workdir\AllTranslators\new\obj2glb-translator\node_modules\cesium\Build\CesiumUnminified\index.cjs:14950:11) at createVertex (D:\workdir\AllTranslators\new\obj2glb-translator\node_modules\obj2gltf\lib\loadObj.js:233:15) at addVertex (D:\workdir\AllTranslators\new\obj2glb-translator\node_modules\obj2gltf\lib\loadObj.js:260:7) at addFace (D:\workdir\AllTranslators\new\obj2glb-translator\node_modules\obj2gltf\lib\loadObj.js:374:23) at parseLine (D:\workdir\AllTranslators\new\obj2glb-translator\node_modules\obj2gltf\lib\loadObj.js:482:11) at Interface.callbackWrapper (D:\workdir\AllTranslators\new\obj2glb-translator\node_modules\obj2gltf\lib\readLines.js:30:11) at Interface.emit (events.js:400:28) at Interface._onLine (readline.js:434:10) at Interface._normalWrite (readline.js:588:12) at ReadStream.ondata (readline.js:246:10) at ReadStream.emit (events.js:400:28) at addChunk (internal/streams/readable.js:293:12) at readableAddChunk (internal/streams/readable.js:267:9) at ReadStream.Readable.push (internal/streams/readable.js:206:10) at internal/fs/streams.js:190:14 at FSReqCallback.wrapper [as oncomplete] (fs.js:563:5) model.zip

The fix is to close the linereader in file /lib/readline.js line no. 32 function readLines(path, callback) { const stream = fsExtra.createReadStream(path); return events.once(stream, "open").then(function () { return new Promise(function (resolve, reject) { stream.on("error", reject); stream.on("end", resolve); const lineReader = readline.createInterface({ input: stream, });

  const callbackWrapper = function (line) {
    try {
      callback(line);
    } catch (error) {
      lineReader.close();
      reject(error);
    }
  };

  lineReader.on("line", callbackWrapper);

});

}); }

Apidcloud commented 3 months ago

I have the exact same issue with the following file. It's causing the socket to hang. faulty.obj.zip