-
Notifications
You must be signed in to change notification settings - Fork 42
Description
Using msnodesqlv8 v5.1.1 with sqlserver2022
The following line sporadically crashes with error message Unhandled exception at 0x00007FF84E30D7CD (ntdll.dll) in <xxx.exe>.dmp: 0xC0000005: Access violation writing location 0x0000000000000010. because the handle was already freed
| auto cancelResult = SQLCancel(handle->get_handle()); |
i suspect the following function has already cleared the statement form the collection
node-sqlserver-v8/cpp/src/odbc/connection_handles.cpp
Lines 165 to 178 in 42539dc
| void ConnectionHandles::checkin(long statementId) { | |
| SQL_LOG_DEBUG_STREAM("ConnectionHandles::checkin - statementId = " << statementId); | |
| const auto itr = _statementHandles.find(statementId); | |
| if (itr == _statementHandles.end()) { | |
| SQL_LOG_ERROR_STREAM( | |
| "ConnectionHandles::checkin - no handle found for statementId = " << statementId); | |
| return; | |
| } | |
| // Free the handle through SafeHandle | |
| itr->second->free(); | |
| _statementHandles.erase(statementId); | |
| } |
Because the calling function OdbcConnection::RemoveStatement() doesn't lock the _connectionMutex and OdbcConnection::Close() doesn't lock the _statementMutex
The client application runs a query using the following function chain
sql.open(connectionString, (err, conn) => {
if (err) {
...
} else {
var pm = conn.procedureMgr();
pm.setTimeout(timeout);
pm.getProc(queryName, (err, procedure) => {
if(err) {
conn.close(() => {...});
} else {
var query = procedure.call(args);
query.on('done', () => {
conn.close(() => {...});
});
query.on('error', err => {
conn.close(() => {...});
});
query.on('info', i => {...});
query.on('meta', meta => {...});
query.on('column', (index, data) => {...});
query.on('row', index => {...});
query.on('free', () => {...});
}
}
});There wasn't any running parallel API calls.