node-odbc icon indicating copy to clipboard operation
node-odbc copied to clipboard

[BUG] Library crashes with segfault when opening database connection

Open natefabian18 opened this issue 3 months ago • 0 comments

Describe your system

  • odbc Package Version: 2.4.9
  • ODBC Driver: msodbcsql17
  • Database Name: master
  • Database Version: Microsoft SQL Server 2022 (RTM-CU15-GDR) (KB5046862) - 16.0.4155.4 (X64) Oct 18 2024 16:16:11 Copyright (C) 2022 Microsoft Corporation Developer Edition (64-bit) on Linux (Ubuntu 22.04.5 LTS) <X64>
  • Database OS: Linux (Docker)
  • Node.js Version: 20
  • Node.js OS: Linux (Docker)

Describe the bug ODBC Library crashes with segfault when opening database connection

Expected behavior The database is opened and queries can be executed

To Reproduce Reproduction available in this repositories docker compose, See project readme. Namely running the willCrash.js with node

Code If applicable, add snippets of code to show:

  • The offending code:
const odbc = require("odbc");
require('dotenv').config()

async function connectToDatabase() {
	let database = process.env.DB || 'db'
	let password = process.env.PASS || 'DATABASE_PASSWORD1!'
	let connString = `Driver={ODBC Driver 17 for SQL Server};Server=${database};Database=master;Uid=sa;Pwd=${password};`;
	console.log(`Connecting with connString: ${connString}`);
	const connection = await odbc.connect(connString);
	const result = await connection.query("select * from INFORMATION_SCHEMA.COLUMNS");
	console.log(result);
}

connectToDatabase().catch((e) => console.log(e));
  • Any DEBUG information printed to the terminal: (Segfault)

GDB Debug output

Starting program: /usr/local/bin/node willCrash.js
warning: Error disabling address space randomization: Operation not permitted
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7f3d61bda6c0 (LWP 61)]
[New Thread 0x7f3d613d96c0 (LWP 62)]
[New Thread 0x7f3d60bd86c0 (LWP 63)]
[New Thread 0x7f3d5bfff6c0 (LWP 64)]
[New Thread 0x7f3d5b7fe6c0 (LWP 65)]
[New Thread 0x7f3d603366c0 (LWP 66)]
Connecting with connString: Driver={ODBC Driver 17 for SQL Server};Server=db;Database=master;Uid=sa;Pwd=DATABASE_PASSWORD1!;
[New Thread 0x7f3d3afbf6c0 (LWP 67)]
[New Thread 0x7f3d3a7be6c0 (LWP 68)]
[New Thread 0x7f3d39fbd6c0 (LWP 69)]
[New Thread 0x7f3d397bc6c0 (LWP 70)]

Thread 8 "node" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f3d3afbf6c0 (LWP 67)]
0x0000000001a9141a in SSL_SESSION_free ()
  • Any error information returned from a function call:

Additional context Add any other context about the problem here.

natefabian18 avatar Nov 14 '24 18:11 natefabian18