Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#1029704: connect() fails with malloc(): unsorted double linked list corrupted

362 views
Skip to first unread message

Andreas Pflug

unread,
Jan 26, 2023, 7:50:04 AM1/26/23
to
Package: python3-pymssql
Version: 2.1.4+dfsg-3+b3

When re-connecting to an MSSQL server after a connection error, the
program will stop with "malloc(): unsorted double linked list corrupted"

This can be reproduced on Debian 11.6 (amd64) with latest dist-upgrade
applied using the following program. The test program will run in a
loop, doing heavy work, and reconnect if the connection should fail.

A malicious administrator might kill the database connection:

DECLARE @spid INT
SELECT @spid=spid FROM sys.sysprocesses
WHERE program_name LIKE 'Trigger Error %'
EXEC ('KILL ' + @spid)

The application should create a new connection and go on, but in most
cases the malloc() abort will happen.



#! /usr/bin/python3
##########################################################
import os, json, pymssql

"""
Configuration in ~/db.secrets
{
"server": "serverAddress",
"database": "theDatabase",
"username": "theUser",
"password": "secrets"
}
"""
with open(f"{os.path.expanduser('~')}/db.secrets") as fp:
cfg=json.load(fp)

def getCursor(appname):
print("Making new connection", appname)
conn=pymssql.connect(cfg['server'], cfg['username'],
cfg['password'], cfg['database'],
port=cfg.get('port', 1433), as_dict=True,
timeout=20, login_timeout=5,
appname=appname)
return conn.cursor()

generation=1
cursor=None
while True:
if not cursor:
cursor=getCursor(f"Trigger Error {generation}")
try:
print("Executing generation", generation)
cursor.execute("WAITFOR DELAY '00:00:01'")
except (pymssql.OperationalError, pymssql.InterfaceError) as e:
print("Aborted", e)
cursor=None
generation += 1

Andreas Pflug

unread,
Jan 26, 2023, 12:10:04 PM1/26/23
to
Testing against docker images gives the same error. Tested:

python:3.9.1-slim-bullseye
python:3.10.9-slim-bullseye
python:3.11.1-slim-bullseye

Andreas Pflug

unread,
Jan 26, 2023, 12:50:04 PM1/26/23
to
0 new messages