Arithmetic overflow exception when opening SQL connection
Asked Answered
A

6

15

I got very weird ArithmeticOverflowException when opening an SQL connection to the underlying SQL database (stack trace included below). It doesn't make a difference which version of the server is used (I've verified MS SQL 2005/2008/2012/2014), error is still the same. All the newest updates and patches from Windows Update installed. OS is Windows 8.1 / 10 (same occurs on both systems). Server is installed locally and the connection is made via user and password. Connection timeout verified in range from 15 to 1000 sec.

The most surprising thing is the application works just fine, and communicates with the server properly, executing many various queries, but suddenly this exception occurs. I noticed this exception started showing up after some windows update (no idea which one).

I've looked into the .NET code, but have no idea what can cause the arithmetic overflow exception there...

-- STACK TRACE --

in SNIOpenSyncExWrapper(SNI_CLIENT_CONSUMER_INFO* , SNI_ConnWrapper** )
in SNINativeMethodWrapper.SNIOpenSyncEx(ConsumerInfo consumerInfo, String constring, IntPtr& pConn, Byte[] spnBuffer, Byte[] instanceName, Boolean fOverrideCache, Boolean fSync, Int32 timeout, Boolean fParallel)
in System.Data.SqlClient.SNIHandle..ctor(ConsumerInfo myInfo, String serverName, Byte[] spnBuffer, Boolean ignoreSniOpenTimeout, Int32 timeout, Byte[]& instanceName, Boolean flushCache, Boolean fSync, Boolean fParallel)
in System.Data.SqlClient.TdsParserStateObject.CreatePhysicalSNIHandle(String serverName, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Byte[]& instanceName, Byte[] spnBuffer, Boolean flushCache, Boolean async, Boolean fParallel)
in System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover)
in System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
in System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
in System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
in System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData)
in System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
in System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
in System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
in System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
in System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
in System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
in System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
in System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
in System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
in System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
in System.Data.SqlClient.SqlConnection.Open()
Anagram answered 16/9, 2015 at 12:49 Comment(11)
I don't suppose you're able to consistently reproduce this? Is it just one application or several?Cerys
is there a checked integer addition anywhere in your code? can you post the full exception please?Bulbar
@Dan Field - It's reproducable from time to time and even quite often - not sure under what conditions, since this exception had occured on few of my customer's machines. Thus I can't debug the code myself :/ And exactly the same problem I have in three different applications (the stack trace is same).Anagram
@Bulbar There is nothing like this in my code, since I do not do any computations related to the connection - the exception occurs in core .net code. The trace shown above is the full stack trace from the exception (previous operations, before the Open method on SqlConnection is called, are not relevant at all). And by the way - this is a call from single thread. It's not the case multiple threads try open the connection.Anagram
Do you know which line of code the error happens on, and can you post it and the block of code that contains it?Percyperdido
you're going to have to determine where the error is occurring and show code here. Find out the exact steps users are doing to experience the error, what records it occurs on. then take a copy of the database and copy their steps, setting breakpoints to figure out what is going on. Right now there is not enough information to determine the cause of the error.Bulbar
@Bulbar As it's shown in the stack trace - the error occurs in SNIOpenSyncExWrapper. It's the .NET framework's class, not mine :) The database has nothing to do with this exception - it's not related to data at all, this is just Open method on connection called, where the exception occurs. I hope someone have experienced same problem and found the solution already.Anagram
tbh might be best to log a ticket with microsoft support.Bulbar
@Tab Alleman - Unfortunately since the exception comes from the insides of .net you won't get any line numbers. The stack is the only thing I have. And if only it had occured on my computer, I'd be able to download .net sources and debug it, but nope - works as a charm on my side :/Anagram
Since it only happens on one machine I doubt it is a MS error. Are there any login triggers on their database?Vicinal
@Sean Lange - It happens on many machines, not on one. There are no login triggers on the database.Anagram
C
20

I had the same problem. Lavasoft was also a reason. I checked in Program and Features if there is any Lavasoft program, and I was surprised to find application called WebCompanion of Lavasoft. I also found a running service LavasoftTcpService.

  1. I stopped the service LavasoftTcpService (from services.msc)
  2. I uninstalled WebCompanion from Program and Features.
  3. Two above mentioned dlls (LavasoftTcpService.dll and LavasoftTcpService64.dll in C:\Windows\System32 and C:\Windows\SysWOW64) were still there. I changed their name, and a problem dissapeared.

Before those steps I tried to only change dlls names and there was a problem to resolve localhost: instead of 127.0.0.1 system was looking for 0.0.0.0. Ping was giving me an error message "Ping request could not find host localhost. Please check the name and try again"

3 steps resolved the problem.

Cameliacamella answered 19/7, 2016 at 6:39 Comment(3)
I applied the steps and I've been checking for couple of days and it seems it helped. The problem didn't occur from that moment. Maybe it should be complained to Lavasoft or something...Assembled
Thank you for this, I really wasn't able to understand what was happening to my colleague sql server, any call to Open connection from a C# program gave this absurd overflow error on SQL Client. Someone should send a message to Lavasoft.Hexone
I'm not able to see the root of the problem, but it's simply working. Thanks a lot!Inextirpable
P
11

We had the same problem and it was caused by LavasoftTcpService64.dll. Getting rid of this, which is not that easy, fixed the problem. Check the following folders for its presence: C:\Windows, C:\Windows\System32 and C:\Windows\SysWOW64.

Credit goes to Nguyen Quy Hy for finding the root cause.

Proto answered 29/9, 2015 at 10:59 Comment(1)
There are other cases as well, like this SO question that are caused by a different issue.Disentail
C
3

I confirm the culprit is Lavasoft Ad-Aware or WebCompanion. The System.OverflowException is thrown when calling SqlConnection.Open(). Only with LocalDB.

Interestingly, the crash occurs always if your app is a single instance application, otherwise it occurs randomly.

The solution is what Ursula said.

Cyaneous answered 25/11, 2016 at 8:27 Comment(0)
B
2

I had the same problem which prevented installation of Azure Storage Emulator i.e. AzureStorageEmulator.exe start produced a similar stack trace and exception. I could init the emulator but not start it. Removal of the Lavasoft dll and resetting the winsock stack did the trick. So worked for me and likewise credit to Nguyen Quy Hy and this post.

Biron answered 14/10, 2015 at 19:23 Comment(0)
P
2

i had the same problem while creating user through entityframework and i found the solution and fix the problem by doing following steps

  1. Stop LavasoftTcpService64 service from services and
  2. Uninstall the web-companion from program and features and it started working in case if the problem still exist restart your machine hope it will help.
Poona answered 31/7, 2017 at 16:30 Comment(0)
J
1

I Just encountered this error myself and option #2 from here helped me.

  1. Please, start Command Prompt as an administrator by right-clicking it and select Run as administrator.

  2. Enter this command to reset the network adapter (end with the Enter key):
    netsh winsock reset

  3. Restart the computer.

  4. Please, delete these two files:
    C:\WINDOWS\system32\LavasoftTcpService64.dll C:\WINDOWS\SysWOW64\LavasoftTcpService.dll (only for 64-bit Windows)

I renamed the files instead of deleting.

Jan answered 11/6, 2017 at 8:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.