nodejs / help

:sparkles: Need help with Node.js? File an Issue here. :rocket:
1.47k stars 280 forks source link

node program prints a stack trace then terminates. The stack trace is not a normal node stack trace (or at least if it is it's formatted very strangley) #4322

Closed markddrake closed 2 months ago

markddrake commented 9 months ago

Details

My node program is printing out the following message and then terminating.

Stacktrace:
    ptr1=0x978432a6291
    ptr2=(nil)
    ptr3=(nil)
    ptr4=(nil)
    ptr5=(nil)
    ptr6=(nil)
    failure_message_object=0x7ffeab732320

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x7ffb6bea53f6]
    1: /* anonymous */ [0x1ed79fb75161] [file:///usr/src/YADAMU/src/node/dbi/loader/csvLibrary.js:~34] [pc=0x7ffb4c820afb](this=0x1ed79fb74fc9 <JSArray[6]>,0x1ed79fb74dd9 <Writable map = 0x66662ce5611>,0x0978432a6291 <FreeSpace[32]>)
    2: writeBatchAsCSV [0x1010a7990eb1] [file:///usr/src/YADAMU/src/node/dbi/vertica/verticaWriter.js:~50] [pc=0x7ffb4c8045b3](this=0x063552b0b4d9 <Writable map = 0x1d3e40438149>,0x1ed79fb74cb1 <String[85]: c"/usr/src/YADAMU/stagingArea/db/vertica/YST-587A0480939890A8621499FEF5D95E03-00056.001">,0x063552b0b301 <JSArray[10000]>)
    3: _writeBatch [0x1010a7990fc9] [file:///usr/src/YADAMU/src/node/dbi/vertica/verticaWriter.js:~136] [pc=0x7ffb4c10ff08](this=0x063552b0b4d9 <Writable map = 0x1d3e40438149>,0x063552b0b0e9 <Object map = 0x1e1f5466b829>,10000)
    4: /* anonymous */ [0x43e14ed2681](this=0x35214edc1171 <JSGlobalProxy>,0x08f5bd7803e1 <undefined>)
    5: StubFrame [pc: 0x7ffb6bf15d31]
    6: StubFrame [pc: 0x7ffb6be374e8]
    7: EntryFrame [pc: 0x7ffb6be0aa43]
    8: ExitFrame [pc: 0x7ffb6be0ec3e]
    9: processTicksAndRejections [0x35214edc6f49] [node:internal/process/task_queues:~67] [pc=0x7ffb4c761170](this=0x35214edc28d1 <process map = 0x1e1f5467faf1>)
   10: InternalFrame [pc: 0x7ffb6be0ab1c]
   11: EntryFrame [pc: 0x7ffb6be0a843]

==== Details ================================================

[0]: ExitFrame [pc: 0x7ffb6bea53f6]
[1]: /* anonymous */ [0x1ed79fb75161] [file:///usr/src/YADAMU/src/node/dbi/loader/csvLibrary.js:~34] [pc=0x7ffb4c820afb](this=0x1ed79fb74fc9 <JSArray[6]>,0x1ed79fb74dd9 <Writable map = 0x66662ce5611>,0x0978432a6291 <FreeSpace[32]>) {
// optimized frame
--------- s o u r c e   c o d e ---------
function (os,col) => {\x0d\x0a\x09\x09      // sw.write(JSON.stringify(col));\x0d\x0a              os.write('"')\x0d\x0a\x09  \x09      os.write(col.indexOf('"') > -1 ? col.replace(/"/g,'""') : col)\x0d\x0a\x09\x09      os.write('",')\x0d\x0a\x09\x09    }
-----------------------------------------
}
[2]: writeBatchAsCSV [0x1010a7990eb1] [file:///usr/src/YADAMU/src/node/dbi/vertica/verticaWriter.js:~50] [pc=0x7ffb4c8045b3](this=0x063552b0b4d9 <Writable map = 0x1d3e40438149>,0x1ed79fb74cb1 <String[85]: c"/usr/src/YADAMU/stagingArea/db/vertica/YST-587A0480939890A8621499FEF5D95E03-00056.001">,0x063552b0b301 <JSArray[10000]>) {
// optimized frame
--------- s o u r c e   c o d e ---------
function writeBatchAsCSV(filename,batch) {\x0d\x0a    const sw = new StringWriter();\x0d\x0a    const csvTransformations = CSVLibrary.getCSVTransformations(batch,this.tableInfo.targetDataTypes)\x0d\x0a    CSVLibrary.writeBatchAsCSV(sw,batch,csvTransformations)\x0d\x0a    let stack\x0d\x0a    try {\x0d\x0a      stack = new Error().stack\x0d\x0a      await fsp.write...

-----------------------------------------
}
[3]: _writeBatch [0x1010a7990fc9] [file:///usr/src/YADAMU/src/node/dbi/vertica/verticaWriter.js:~136] [pc=0x7ffb4c10ff08](this=0x063552b0b4d9 <Writable map = 0x1d3e40438149>,0x063552b0b0e9 <Object map = 0x1e1f5466b829>,10000) {
  // heap-allocated locals
  var this = 0x063552b0b4d9 <Writable map = 0x1d3e40438149>
  var rejectedRecordsTableName = 0x043e14ed29a1 <String[36]: c"YRT-90F265D3AF6BBAA1129DE01AC44A537E">
  var copyOperations = 0x043e14ed29c1 <Object map = 0x2009ad9ff269>
  // expression stack (top to bottom)
  [41] : 0x063552b0b4d9 <Writable map = 0x1d3e40438149>
  [40] : 0x1ed79fb74cb1 <String[85]: c"/usr/src/YADAMU/stagingArea/db/vertica/YST-587A0480939890A8621499FEF5D95E03-00056.001">
  [39] : 0x063552b0b301 <JSArray[10000]>
  [38] : 0x08f5bd7803e1 <undefined>
  [37] : 0x08f5bd7803e1 <undefined>
  [36] : 0x08f5bd7803e1 <undefined>
  [35] : 0x08f5bd7803e1 <undefined>
  [34] : 0x08f5bd7803e1 <undefined>
  [33] : 0x08f5bd7803e1 <undefined>
  [32] : 0x063552b0b301 <JSArray[10000]>
  [31] : 3
  [30] : 0x063552b0b4d9 <Writable map = 0x1d3e40438149>
  [29] : 0x1010a7990eb1 <JSFunction writeBatchAsCSV (sfi = 0x297fb39db821)>
  [28] : 0x043e14ed2739 <FunctionContext[5]>
  [27] : 0
  [26] : 1
  [25] : 0x043e14ed2989 <FixedArray[1]>
  [24] : 0x043e14ed2989 <FixedArray[1]>
  [23] : 0x043e14ed2969 <JSArray[1]>
  [22] : 0x043e14ed2739 <FunctionContext[5]>
  [21] : 0x0b64f8f14391 <BlockContext[4]>
  [20] : 0x08f5bd7803e1 <undefined>
  [19] : 0x08f5bd7803e1 <undefined>
  [18] : 0x08f5bd7803e1 <undefined>
  [17] : 0x08f5bd7803e1 <undefined>
  [16] : 0x08f5bd7803e1 <undefined>
  [15] : 0x1ed79fb74cb1 <String[85]: c"/usr/src/YADAMU/stagingArea/db/vertica/YST-587A0480939890A8621499FEF5D95E03-00056.001">
  [14] : 0x1ed79fb74c31 <String[46]: c"YST-587A0480939890A8621499FEF5D95E03-00056.001">
  [13] : 0x19fe14b087f9 <String[4]: #copy>
  [12] : 0x08f5bd784629 <String[1]: #0>
  [11] : 0x08f5bd7803e1 <undefined>
  [10] : 0x08f5bd7803e1 <undefined>
  [09] : 0x08f5bd7803e1 <undefined>
  [08] : 0x08f5bd7803e1 <undefined>
  [07] : 0x08f5bd7803e1 <undefined>
  [06] : 0x08f5bd7803e1 <undefined>
  [05] : 0x08f5bd784629 <String[1]: #0>
  [04] : 0x08f5bd7803e1 <undefined>
  [03] : 0x043e14ed2969 <JSArray[1]>
  [02] : 0x043e14ed2949 <String[42]: c"YST-587A0480939890A8621499FEF5D95E03-00056">
  [01] : 0x043e14ed2929 <JSArray[0]>
  [00] : 0x043e14ed26e1 <JSAsyncFunctionObject>
--------- s o u r c e   c o d e ---------
function _writeBatch(batch,rowCount) {\x0d\x0a\x0d\x0a    // console.log(batch)\x0d\x0a      \x0d\x0a    const emptyStringDataSets = Object.keys(batch).filter((key) => {return ((key !== 'copy') && (key !== 'insert'))})\x0d\x0a    delete emptyStringDataSets.copy\x0d\x0a    delete emptyStringDataSets.insert\x0d\x0a\x0d\x0a    let rejectedRecordsTableName = `YRT-${cryp...

-----------------------------------------
}

[4]: /* anonymous */ [0x43e14ed2681](this=0x35214edc1171 <JSGlobalProxy>,0x08f5bd7803e1 <undefined>) {
// optimized frame
--------- s o u r c e   c o d e ---------
<No Source>
-----------------------------------------
}
[5]: StubFrame [pc: 0x7ffb6bf15d31]
[6]: StubFrame [pc: 0x7ffb6be374e8]
[7]: EntryFrame [pc: 0x7ffb6be0aa43]
[8]: ExitFrame [pc: 0x7ffb6be0ec3e]
[9]: processTicksAndRejections [0x35214edc6f49] [node:internal/process/task_queues:~67] [pc=0x7ffb4c761170](this=0x35214edc28d1 <process map = 0x1e1f5467faf1>) {
// optimized frame
--------- s o u r c e   c o d e ---------
function processTicksAndRejections() {\x0a  let tock;\x0a  do {\x0a    while ((tock = queue.shift()) !== null) {\x0a      const asyncId = tock[async_id_symbol];\x0a      emitBefore(asyncId, tock[trigger_async_id_symbol], tock);\x0a\x0a      try {\x0a        const callback = tock.callback;\x0a        if (tock.args === undefined) {\x0a          callback();\x0a       ...

-----------------------------------------
}
[10]: InternalFrame [pc: 0x7ffb6be0ab1c]
[11]: EntryFrame [pc: 0x7ffb6be0a843]
=====================

Looking for some hints on where to start debugging...

FWIW the code is using the 'pg' library to work with a Vertica 10 database. The same code and client stack works perfectly against a Vertica 23 database, and the database code does not appear in the stack trace.

Given the above stack I have no idea what went wrong, endless loop?, out of memory ?.....

Node.js version

v21.2.0

Example code

No response

Operating system

Ubuntu

Scope

Runtime process crash

Module and version

Not applicable.

preveen-stack commented 9 months ago

it seems like an issue is occurring in the csvLibrary.js file at line 34 and in the verticaWriter.js file at line 50.

RedYetiDev commented 3 months ago

@markddrake did @preveen-stack's suggestion help?

markddrake commented 3 months ago

Attempting to Bite Tongue.... I'm afraid it did not tell me anything I was not aware of at the point i posted.

RedYetiDev commented 3 months ago

If it's still outstanding, can you provide a minimal reproducible example?

(FWIW the stack trace is from Node.js's CPP)

RedYetiDev commented 3 months ago

This needs more info for 2 weeks. I'll be closing this issue if more information isn't provided in the next few days.