Search

SQLDriverConnect leaks memory on failure by kertj1

Closed
as Not Reproducible Help for as Not Reproducible

1
0
Sign in
to vote
Type: Bug
ID: 767248
Opened: 10/12/2012 1:17:59 PM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
Hi,

I'm using the (newly released) Microsoft ODBC driver for Linux:
"Driver=SQL Server Native Client 11.0"
Specifically: sqlncli-11.0.1790.0.tar.gz

I am using the Linux tool "valgrind" on a small test program that
just tries to establish a database connection and then disconnects,
for example:

SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &h_env);
SQLSetEnvAttr(h_env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER*)SQL_OV_ODBC3, 0);
SQLAllocHandle(SQL_HANDLE_DBC, h_env, &h_dbc);
SQLDriverConnect(h_dbc, NULL, ...
SQLDisconnect(h_dbc);
SQLFreeHandle(SQL_HANDLE_DBC, h_dbc);
SQLFreeHandle(SQL_HANDLE_ENV, h_env);

When the call to SQLDriverConnect is successful, valgrind reports
that no memory has been leaked.

When the call to SQLDriverConnect fails for whatever reason
(for example: database offline, host down, etc...), each call
to SQLDriverConnect leaks 1034 bytes of memory.

I have tried invoking SQLGetDiagRec() to free the memory but that didn't help.

Any suggestions on how to avoid the memory leak?

Thanks,
Kert
Details (expand)

Product Language

English

Version

SQL Server 2008 R2 SP1

Category

Master Data Services

Operating System

Other

Operating System Language

US English

Steps to Reproduce

SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &h_env);
SQLSetEnvAttr(h_env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER*)SQL_OV_ODBC3, 0);
SQLAllocHandle(SQL_HANDLE_DBC, h_env, &h_dbc);
SQLDriverConnect(h_dbc, NULL, ...
SQLDisconnect(h_dbc);
SQLFreeHandle(SQL_HANDLE_DBC, h_dbc);
SQLFreeHandle(SQL_HANDLE_ENV, h_env);

When the call to SQLDriverConnect is successful, valgrind reports
that no memory has been leaked.

When the call to SQLDriverConnect fails for whatever reason
(for example: database offline, host down, etc...), each call
to SQLDriverConnect leaks 1034 bytes of memory.

Actual Results

SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &h_env);
SQLSetEnvAttr(h_env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER*)SQL_OV_ODBC3, 0);
SQLAllocHandle(SQL_HANDLE_DBC, h_env, &h_dbc);
SQLDriverConnect(h_dbc, NULL, ...
SQLDisconnect(h_dbc);
SQLFreeHandle(SQL_HANDLE_DBC, h_dbc);
SQLFreeHandle(SQL_HANDLE_ENV, h_env);

When the call to SQLDriverConnect is successful, valgrind reports
that no memory has been leaked.

When the call to SQLDriverConnect fails for whatever reason
(for example: database offline, host down, etc...), each call
to SQLDriverConnect leaks 1034 bytes of memory.

Expected Results

No memory should be leaked when SQLDriverConnect() returns an error.

Platform

X64

Virtualization

 
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 4/15/2013 at 4:21 PM
Thanks for your feedback. Unfortunately we are not able to reproduce the issue.
Sign in to post a workaround.