fast-copy icon indicating copy to clipboard operation
fast-copy copied to clipboard

fast-copy 3.0.0 incompatibility with node-v16.18.1-darwin-arm64

Open jmgoncalves opened this issue 1 year ago • 4 comments

A codebase that works well using fast-copy 2.1.1 on node-v16.18.1-darwin-arm64 breaks if I switch to fast-copy 3.0.0.

/Users/JoaoGoncalves/.nvm/versions/node/v16.17.1/bin/node[49891]: ../src/tcp_wrap.cc:149:static void node::TCPWrap::New(const FunctionCallbackInfo<v8::Value> &): Assertion `args[0]->IsInt32()' failed.
 1: 0x1000b1918 node::Abort() [/Users/JoaoGoncalves/.nvm/versions/node/v16.17.1/bin/node]
 2: 0x1000b175c node::AppendExceptionLine(node::Environment*, v8::Local<v8::Value>, v8::Local<v8::Message>, node::ErrorHandlingMode) [/Users/JoaoGoncalves/.nvm/versions/node/v16.17.1/bin/node]
 3: 0x10015d248 node::TCPWrap::New(v8::FunctionCallbackInfo<v8::Value> const&) [/Users/JoaoGoncalves/.nvm/versions/node/v16.17.1/bin/node]
 ...

Here's the call stack from llnode:

  * thread #1: tid = 0x46403, 0x00000001a7fdb224 libsystem_kernel.dylib`__pthread_kill + 8, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00000001a7fdb224 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x00000001a8011cec libsystem_pthread.dylib`pthread_kill + 288
    frame #2: 0x00000001a7f4b2c8 libsystem_c.dylib`abort + 180
    frame #3: 0x00000001000b1924 node`node::Abort() + 40
    frame #4: 0x00000001000b175c node`node::Assert(node::AssertionInfo const&) + 136
    frame #5: 0x000000010015d248 node`node::TCPWrap::New(v8::FunctionCallbackInfo<v8::Value> const&) + 240
    frame #6: 0x000000010026024c node`v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) + 276
    frame #7: 0x000000010025fa80 node`v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<true>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) + 504
    frame #8: 0x000000010025f5b0 node`v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) + 196
    frame #9: 0x000000010099ecec node`Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit + 108
    frame #10: 0x000000010092fa70 <constructor>
    frame #11: 0x0000000100a2db50 <stub>
    frame #12: 0x0000000100932838 getCleanClone(this=0x34a57a201599:<undefined>, 0xa891fac4741:<Object: Object>) at REDACTED/node_modules/fast-copy/dist/cjs/index.cjs:41:23 fn=0x0000081060d86219
    frame #13: 0x0000000110e2b5d4 copyObjectLooseModern(this=0x34a57a201599:<undefined>, 0x345199629979:<Object: TCP>, 0x21a0bacb8861:<Object: Object>) at REDACTED/node_modules/fast-copy/dist/cjs/index.cjs:212:31 fn=0x0000081060d8e439
    frame #14: 0x0000000100932838 copier(this=0x21a0bacb8861:<Object: Object>, 0x345199629979:<Object: TCP>, 0x21a0bacb8861:<Object: Object>) at REDACTED/node_modules/fast-copy/dist/cjs/index.cjs:349:20 fn=0x000025dc78106e79
    frame #15: 0x0000000110e2b808 copyObjectLooseModern(this=0x34a57a201599:<undefined>, 0x1a351b18d801:<Object: Server>, 0x21a0bacb8861:<Object: Object>) at REDACTED/node_modules/fast-copy/dist/cjs/index.cjs:212:31 fn=0x0000081060d8e439
    frame #16: 0x0000000100932838 copier(this=0x21a0bacb8861:<Object: Object>, 0x1a351b18d801:<Object: Server>, 0x21a0bacb8861:<Object: Object>) at REDACTED/node_modules/fast-copy/dist/cjs/index.cjs:349:20 fn=0x000025dc78106e79
    frame #17: 0x0000000110e2b808 copyObjectLooseModern(this=0x34a57a201599:<undefined>, 0x7f3fbe4ff19:<Object: Socket>, 0x21a0bacb8861:<Object: Object>) at REDACTED/node_modules/fast-copy/dist/cjs/index.cjs:212:31 fn=0x0000081060d8e439
    frame #18: 0x0000000100932838 copier(this=0x21a0bacb8861:<Object: Object>, 0x7f3fbe4ff19:<Object: Socket>, 0x21a0bacb8861:<Object: Object>) at REDACTED/node_modules/fast-copy/dist/cjs/index.cjs:349:20 fn=0x000025dc78106e79
    frame #19: 0x0000000110e2b808 copyObjectLooseModern(this=0x34a57a201599:<undefined>, 0x3438d7cd8ae1:<Object: ServerResponse>, 0x21a0bacb8861:<Object: Object>) at REDACTED/node_modules/fast-copy/dist/cjs/index.cjs:212:31 fn=0x0000081060d8e439
    frame #20: 0x0000000100932838 copier(this=0x21a0bacb8861:<Object: Object>, 0x3438d7cd8ae1:<Object: ServerResponse>, 0x21a0bacb8861:<Object: Object>) at REDACTED/node_modules/fast-copy/dist/cjs/index.cjs:349:20 fn=0x000025dc78106e79
    frame #21: 0x0000000100932838 copyObjectLooseModern(this=0x34a57a201599:<undefined>, 0x21a0bacb7ed9:<Object: Object>, 0x21a0bacb8861:<Object: Object>) at REDACTED/node_modules/fast-copy/dist/cjs/index.cjs:212:31 fn=0x0000081060d8e439
    frame #22: 0x0000000100932838 copier(this=0x21a0bacb8861:<Object: Object>, 0x21a0bacb7ed9:<Object: Object>, 0x21a0bacb8861:<Object: Object>) at REDACTED/node_modules/fast-copy/dist/cjs/index.cjs:349:20 fn=0x000025dc78106e79
    frame #23: 0x0000000100932838 copyObjectLooseModern(this=0x34a57a201599:<undefined>, 0x21a0bacb7c59:<Object: Object>, 0x21a0bacb8861:<Object: Object>) at REDACTED/node_modules/fast-copy/dist/cjs/index.cjs:212:31 fn=0x0000081060d8e439
    frame #24: 0x0000000100932838 copier(this=0x34a57a201599:<undefined>, 0x21a0bacb7c59:<Object: Object>, 0x21a0bacb8861:<Object: Object>) at REDACTED/node_modules/fast-copy/dist/cjs/index.cjs:349:20 fn=0x000025dc78106e79
    frame #25: 0x0000000100932838 copy(this=0x34a57a201599:<undefined>, 0x21a0bacb7c59:<Object: Object>) at REDACTED/node_modules/fast-copy/dist/cjs/index.cjs:373:25 fn=0x000025dc78106949
    frame #26: 0x0000000100932838 filterLog(this=0x34a57a201599:<undefined>, 0x21a0bacb8761:<Object: Object>) at REDACTED/node_modules/pino-pretty/lib/utils.js:591:20 fn=0x000025dc78106501
    frame #27: 0x0000000100932838 pretty(this=0x34a57a201599:<undefined>, 0x21a0bacb7c59:<Object: Object>) at REDACTED/node_modules/pino-pretty/index.js:119:19 fn=0x00000092c6417089
    frame #28: 0x0000000100932838 write(this=0x92c6414359:<Object: Object>, 0x21a0bacb65e1:<String: "{"level":"info",...">) at REDACTED/node_modules/pino/lib/tools.js:1:0 fn=0x00000092c6416699
    frame #29: 0x0000000100932838 write(this=0x21a0bacb3999:<Object: Object>, 0x21a0bacb5e69:<Object: Object>, 0x4de19f2b759:<String: "request complete">, <Smi: 30>) at REDACTED/node_modules/pino/lib/proto.js:1:0 fn=0x000025dc78109759
    frame #30: 0x0000000100932838 LOG(this=0x21a0bacb3999:<Object: Object>, 0x21a0bacb5e69:<Object: Object>) at REDACTED/node_modules/pino/lib/tools.js:1:0 fn=0x000021a0bacb5451
    frame #31: 0x0000000100932838 requestLog(this=0x34a57a201599:<undefined>, 0x3438d7cd8d01:<Object: IncomingMessage>, 0x3438d7cd8ae1:<Object: ServerResponse>, <Smi: 200>, 0x34a57a201599:<undefined>) at (no script):43:20 fn=0x000024bbc39ef3a9
...

I suspect this isn't an issue in x64 but could not confirm yet, will update as soon as I can.

jmgoncalves avatar Dec 05 '22 18:12 jmgoncalves

Hello! I'd like to help, but the stack trace provided offers little in terms of error sourcing because I have no contact on it's use. Can you provide a snippet of how it is being used? Ideally, you could provide a consistent repro as well via example repository or codepen.

planttheidea avatar Dec 05 '22 20:12 planttheidea

Also, since I don't have the contextual use, here are the breaking changes. Maybe something will stand out to you.

planttheidea avatar Dec 05 '22 20:12 planttheidea

From the way it blew up I assumed it was some quirk related to fast-copy's usage of node, but I guess it might not be.

It's being used from https://github.com/pinojs/pino-pretty, specifically these lines https://github.com/pinojs/pino-pretty/blob/v9.1.1/lib/utils.js#LL591-L592 as per the call stack above. It blows up with pino v6.14.0, pino-pretty v9.1.1 and fast-copy 3.0.0, but behaves fine with pino v6.14.0, pino-pretty v8.1.0 and fast-copy 2.1.1.

From my code pino is called to log an object containing a NextApiResponse and the request complete string, as per frame 29 of the call stack.

This is all the info I can provide at this point. Might have time to dig deeper in a week or two - need to update those pino versions anyway... Thanks!

jmgoncalves avatar Dec 06 '22 10:12 jmgoncalves

@jmgoncalves were you using by any chance --disable-proto in your NodeJS process?

castarco avatar Feb 01 '23 09:02 castarco