1

I'm currently working on a Windows 11 Laptop and Ubuntu 22LTS desktop PC. Only on PC the program suddenly interrupts. After some research I found out it's running in an 'Segmentation fault' - error, when loading some data from a postgres DB and creating an Object with it. The error occurs as soon as the constructor is called.

import SegFaultHandler from 'segfault-handler'

SegFaultHandler.registerHandler("crash.log")

export async function _init(containerName) {
    let sqlQueries = {
        loadItemData: {
            syntax: 'select * from containercontent where itemname = $1',
            variables: [containerName],
        },
    };
    let containerData = await dbHandler
        .sqlQuery(sqlQueries.loadItemData.syntax, sqlQueries.loadItemData.variables)
        .then((res) => res.rows[0]);
    let Container = new Container();

    return Container;
}
export class Container extends MarketObject {
    constructor() {...} // <-- the error occurs

I have already reinstalled vsCode, node, npm and all dependencies. I also googled and followed some instructions. One of them was to install the 'segfault-handler'. Now I have a log, but I don't understand it:

PID 35548 received SIGSEGV for address: 0x7c
/home/nox/mega/GitHub/JavaScript/market/node_modules/segfault-handler/build/Release/segfault-handler.node(+0x3340)[0x7f72e3f1d340]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7f72e3842520]
node(_ZNK2v88internal13ScopeIterator15VisitLocalScopeERKSt8functionIFbNS0_6HandleINS0_6StringEEENS3_INS0_6ObjectEEENS1_9ScopeTypeEEENS1_4ModeES8_+0x14d)[0xe4cf1d]
node(_ZN2v88internal13ScopeIterator11ScopeObjectENS1_4ModeE+0x67)[0xe4d667]
node(_ZN2v88internal13DebugEvaluate14ContextBuilderC1EPNS0_7IsolateEPNS0_15JavaScriptFrameEi+0xf0)[0xe3f570]
node(_ZN2v88internal13DebugEvaluate5LocalEPNS0_7IsolateENS0_12StackFrameIdEiNS0_6HandleINS0_6StringEEEb+0x82)[0xe3f7e2]
node(_ZN2v88internal23DebugStackTraceIterator8EvaluateENS_5LocalINS_6StringEEEb+0x60)[0xe4eab0]
node(_ZN12v8_inspector19V8DebuggerAgentImpl19evaluateOnCallFrameERKNS_8String16ES3_N8v8_crdtp6detail10ValueMaybeIS1_EENS6_IbEES8_S8_S8_S8_NS6_IdEEPSt10unique_ptrINS_8protocol7Runtime12RemoteObjectESt14default_deleteISD_EEPNS5_8PtrMaybeINSC_16ExceptionDetailsEEE+0x286)[0x13ac266]
node(_ZN12v8_inspector8protocol8Debugger20DomainDispatcherImpl19evaluateOnCallFrameERKN8v8_crdtp12DispatchableE+0x30f)[0x1633fff]
node(_ZN8v8_crdtp14UberDispatcher14DispatchResult3RunEv+0x1b)[0x13eda6b]
node(_ZN12v8_inspector22V8InspectorSessionImpl23dispatchProtocolMessageENS_10StringViewE+0x1a0)[0x13b9880]
node[0xc8e1fa]
node[0xca7eb1]
node[0xca63ae]
node[0xca66fe]
node[0xca6b1a]
node(_ZN4node11Environment21RunAndClearInterruptsEv+0x148)[0xb0a378]
node(_ZN4node9inspector19NodeInspectorClient21runMessageLoopOnPauseEi+0x8c)[0xc8ed2c]
node(_ZN12v8_inspector10V8Debugger18handleProgramBreakEN2v85LocalINS1_7ContextEEENS2_INS1_5ValueEEERKSt6vectorIiSaIiEENS1_4base7EnumSetINS1_5debug11BreakReasonEiEENSE_13ExceptionTypeEb+0x2e5)[0x1392bb5]
node(_ZN12v8_inspector10V8Debugger21BreakProgramRequestedEN2v85LocalINS1_7ContextEEERKSt6vectorIiSaIiEENS1_4base7EnumSetINS1_5debug11BreakReasonEiEE+0x1a)[0x1392c0a]
node(_ZN2v88internal5Debug12OnDebugBreakENS0_6HandleINS0_10FixedArrayEEENS0_10StepActionENS_4base7EnumSetINS_5debug11BreakReasonEiEE+0x1b2)[0xe5a4a2]
node(_ZN2v88internal5Debug5BreakEPNS0_15JavaScriptFrameENS0_6HandleINS0_10JSFunctionEEE+0x220)[0xe5a6d0]
node(_ZN2v88internal28Runtime_DebugBreakOnBytecodeEiPmPNS0_7IsolateE+0x246)[0x12cf6a6]
node[0x1703c39]
Segmentation fault (core dumped)
Waiting for the debugger to disconnect...

Is anybody able to read some meaningful hint out of it?


New Info:

Seems like the following function after the constructor is causing the error:

export class Container extends MarketObject {
    constructor() {...} // <-- the error occurs
    
    saveDBData = async function () { //<--this function causes the error
        await dbHandler.sqlQuery(this.sqlQueries.saveItemData.syntax, 
           this.sqlQueries.saveItemData.variables);
     }
...
};

Just for your notice, the dbHandler.js looks like this, but I realy don't think its faulty. I'm using this all over the program:

import pg from 'pg';
import ini from 'ini';
import fs from 'fs';
import { error } from 'console';

async function getConnection() {
    try {
        let dbaccess = ini.parse(fs.readFileSync('./tools/database/db.ini', 'utf-8'));
        let client = new pg.Client(dbaccess['postgresql_loginData']);
        return client;
    } catch (error) {
        console.error(error);
        console.error(error.message);
    }
}

export async function sqlQuery(syntax, values) {
    try {
        let client = await getConnection();
        await client.connect();
        let res = await client.query(syntax, values);

        await client.end();

        return res;
    } catch (error) {
        console.error(error.stack);
    }
}
14
  • On a platform like Node, a SIGSEGV nearly always means a bug in the runtime. It's probably triggered by something in your code (well, obviously) but it's not supposed to fail that way.
    – Pointy
    Commented Jul 28, 2023 at 12:56
  • What Node version is it?
    – Pointy
    Commented Jul 28, 2023 at 12:57
  • It's node version 18.17.0 Commented Jul 28, 2023 at 13:21
  • This Node bug report might be of interest. It suggests that some .so.node module you're using (?) may be at fault.
    – Pointy
    Commented Jul 28, 2023 at 13:24
  • I already executed 'npm rebuild'. I also just deleted the node_modules directory ... still the same error Commented Jul 28, 2023 at 13:29

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.