CesiumGS / obj2gltf

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

Lines keep processing after Normal index 2412 is out of bounds Error causing Socket hanging #304

Open Apidcloud opened 3 months ago

Apidcloud commented 3 months ago

Hello!

Uploading the file attached below ends up making the server hang. After a few seconds there's an actual error "Normal index 2412 is out of bounds Error", but it still hangs the whole server -- so future requests never complete. Might be related to https://github.com/CesiumGS/obj2gltf/issues/287

Here's a minimum reproduction repo: https://github.com/Apidcloud/nestjs-sigbus-example/tree/obj-hanging

To test it:

From what I can understand, even after the error is thrown, the lines keep being processed:

image

And actually even before that is thrown, the reject keeps being called interchangeably with also this error "Expected cartesian to be typeof object, actual typeof was undefined":

Error: 
    at new DeveloperError (/Users/ee/workspace/Git/Gitlab/sigbus-nestjs-example/node_modules/cesium/Build/CesiumUnminified/index.cjs:15553:11)
    at Object.Check.typeOf.object (/Users/ee/workspace/Git/Gitlab/sigbus-nestjs-example/node_modules/cesium/Build/CesiumUnminified/index.cjs:15647:11)
    at Function.Cartesian3.normalize (/Users/ee/workspace/Git/Gitlab/sigbus-nestjs-example/node_modules/cesium/Build/CesiumUnminified/index.cjs:17104:24)
    at Object.CoplanarPolygonGeometryLibrary.computeProjectTo2DArguments (/Users/ee/workspace/Git/Gitlab/sigbus-nestjs-example/node_modules/cesium/Build/CesiumUnminified/index.cjs:117378:22)
    at addFace (/Users/ee/workspace/Git/Gitlab/sigbus-nestjs-example/node_modules/obj2gltf/lib/loadObj.js:381:40)
    at parseLine (/Users/ee/workspace/Git/Gitlab/sigbus-nestjs-example/node_modules/obj2gltf/lib/loadObj.js:480:11)
    at Interface.callbackWrapper (/Users/ee/workspace/Git/Gitlab/sigbus-nestjs-example/node_modules/obj2gltf/lib/readLines.js:32:11)
    at Interface.emit (node:events:517:28)
    at Interface.[_onLine] [as _onLine] (node:internal/readline/interface:423:12)
    at Interface.[_normalWrite] [as _normalWrite] (node:internal/readline/interface:617:22)
    at ReadStream.ondata (node:internal/readline/interface:250:23)
    at ReadStream.emit (node:events:517:28)
    at addChunk (node:internal/streams/readable:335:12)
    at readableAddChunk (node:internal/streams/readable:308:9)
    at ReadStream.Readable.push (node:internal/streams/readable:245:10)
    at node:internal/fs/streams:277:14 {
  message: 'Expected cartesian to be typeof object, actual typeof was undefined'
}

The very first error shows up at normal 2412 (and you can see it keeps reading and rejecting):

image

faulty.obj.zip