AccessViolationException when open an oracle connection

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
zhuqijun
Posts: 23
Joined: Fri 05 Jul 2013 06:56

AccessViolationException when open an oracle connection

Post by zhuqijun » Tue 08 Mar 2016 06:15

Hello Support,

We are using Devart DotConnect 7.7.276 to connect to oracle database.

We have a rather large application that's working with multiple parallel OracleConnections.
Sometimes while we calling Open () method, it will never return and the application was freeze.
We created a dump file while it happened;
Cccording to analyse the dump file, we found there was an exception and it was freeze while handling the exception. The exception is:
0:044> !pe 0000000003e619b0
Exception object: 0000000003e619b0
Exception type: Devart.Data.Oracle.OracleException
Message: Internal exception in Oracle client occurred.
InnerException: System.AccessViolationException, use !PrintException 0000000003e606b8 to see more
StackTrace (generated):
SP IP Function
000000005584D210 000007FF0138CC9D Devart_Data_Oracle!Devart.Data.Oracle.aq.a(Devart.Data.Oracle.b7, Devart.Data.Oracle.p)+0x14d
000000005584D260 000007FF013893A4 Devart_Data_Oracle!Devart.Data.Oracle.OracleInternalConnection..ctor(Devart.Data.Oracle.b7, Devart.Data.Oracle.OracleInternalConnection)+0x204

StackTraceString: <none>
HResult: 80004005
0:044> !pe 0000000003e606b8
Exception object: 0000000003e606b8
Exception type: System.AccessViolationException
Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
InnerException: <none>
StackTrace (generated):
SP IP Function
000000001E018B30 0000000000000001 UNKNOWN!UNKNOWN+0x2
000000001E018BF0 000007FF01447FAA UNKNOWN!UNKNOWN+0x2a
000000001E018C30 000007FF0138F01A Devart_Data_Oracle!Devart.Data.Oracle.aq.b(System.Object)+0x22fa

StackTraceString: <none>
HResult: 80004003

Below is the source code that we open a connection:
using (var con = new OracleConnection(Connection) { Unicode = true })
{
con.Open();

Below are the call stacks of the freeze thread:
0:044> !dumpstack
OS Thread Id: 0xc98 (44)
Child-SP RetAddr Call Site
000000005584a338 0000000077319088 ntdll!ZwWaitForSingleObject+0xa
000000005584a340 0000000077318f84 ntdll!RtlpWaitOnCriticalSection+0xe8
000000005584a3f0 000000001fb6a244 ntdll!RtlEnterCriticalSection+0xd1
000000005584a420 000000001f5e17fa oracore11!sltsmna+0x1c
000000005584a450 000000001f6f85b9 OraClient11!kpuhhfrh+0x67c
000000005584a690 000000001f6f6c6c OraClient11!kpufhndl0+0x1939
000000005584a960 000000001f5a6d75 OraClient11!kpufhndl+0xe
000000005584a990 0000000180003535 OraClient11!OCIHandleFree+0x15
000000005584a9c0 000007fefa08bec7 oci!OCIHandleFree+0x71
000000005584aa00 000007ff01443285 mscorwks!DoNDirectCall__PatchGetThreadCall+0x7b
000000005584aaa0 000007ff01447fa9 System_Configuration!DomainBoundILStubClass.IL_STUB(System.Runtime.InteropServices.HandleRef, Int32)+0x1443286
000000005584ab60 000007ff01509d6e UNKNOWN+0x29
000000005584aba0 000007ff015095e6 Devart_Data_Oracle!Devart.Data.Oracle.a0.c()+0x1be
000000005584ac80 000007ff01ac9355 Devart_Data_Oracle!Devart.Data.Oracle.aq.c()+0x706
000000005584ae90 000007ff01389483 Devart_Data_Oracle!Devart.Data.Oracle.aq.p()+0x15
000000005584aec0 000007fef9fe5d0d Devart_Data_Oracle!Devart.Data.Oracle.OracleInternalConnection..ctor(Devart.Data.Oracle.b7, Devart.Data.Oracle.OracleInternalConnection)+0x2e3
000000005584af30 000007fef9fffe4a mscorwks!ExceptionTracker::CallHandler+0x145
000000005584b030 000007fef9f6c31b mscorwks!ExceptionTracker::CallCatchHandler+0x9e
000000005584b0c0 00000000772f826d mscorwks!ProcessCLRException+0x2ab
000000005584b160 00000000772e7e5c ntdll!RtlpExecuteHandlerForUnwind+0xd
000000005584b190 000007fef9eee48e ntdll!RtlUnwindEx+0x539
000000005584b830 000007fef9f6c2c7 mscorwks!ClrUnwindEx+0x36
000000005584bd40 00000000772f81ed mscorwks!ProcessCLRException+0x257
000000005584bde0 00000000772e85df ntdll!RtlpExecuteHandlerForException+0xd
000000005584be10 00000000772e8bd8 ntdll!RtlDispatchException+0x45a
000000005584c4f0 000007fefd34adcd ntdll!RtlRaiseException+0x22f
000000005584cea0 000007fef9f2b943 KERNELBASE!RaiseException+0x39
000000005584cf70 000007fefa4d1cf0 mscorwks!RaiseTheExceptionInternalOnly+0x2ff
000000005584d060 000007ff0138cc9c mscorwks!JIT_Throw+0x130
000000005584d210 000007ff013893a3 Devart_Data_Oracle!Devart.Data.Oracle.aq.a(Devart.Data.Oracle.b7, Devart.Data.Oracle.p)+0x14c
000000005584d260 000007ff01389174 Devart_Data_Oracle!Devart.Data.Oracle.OracleInternalConnection..ctor(Devart.Data.Oracle.b7, Devart.Data.Oracle.OracleInternalConnection)+0x203
000000005584d2f0 000007ff0142a30d Devart_Data_Oracle!Devart.Data.Oracle.ap.a(Devart.Common.p, System.Object, Devart.Common.DbConnectionBase)+0x94
000000005584d330 000007ff01386cff Devart_Data_Oracle!Devart.Common.DbConnectionFactory.a(Devart.Common.DbConnectionBase, Devart.Common.p)+0x9d
000000005584d3d0 000007ff01386b42 Devart_Data_Oracle!Devart.Common.DbConnectionFactory.b(Devart.Common.DbConnectionBase)+0x6f
000000005584d440 000007ff013866a0 Devart_Data_Oracle!Devart.Common.DbConnectionClosed.Open(Devart.Common.DbConnectionBase)+0x82
000000005584d4a0 000007ff0137fdd8 Devart_Data_Oracle!Devart.Common.DbConnectionBase.Open()+0xb0
000000005584d520 000007ff0185db11 Devart_Data_Oracle!Devart.Data.Oracle.OracleConnection.Open()+0x128


Could you tell me what the issue is and how to solve it?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: AccessViolationException when open an oracle connection

Post by Shalex » Tue 08 Mar 2016 13:20

OracleConnection instance is not guaranteed to be thread safe. You should avoid using the same OracleConnection in several threads at the same time. It is recommended to open a new connection per thread and to close it when the work is done. Actually, connections will not be created/disposed every time with the Pooling=true; connection string option, because connections will be stored at connection pool. This boosts performance greatly.
A single OracleConnection can be used by many OracleCommand objects on the assumption that all operations will be done consecutively. In other words, you can not execute a SQL statement while an asynchronous operation is in progress.

If this doesn't help, please localize the issue and send us a small test project with the corresponding DDL/DML script for reproducing.

zhuqijun
Posts: 23
Joined: Fri 05 Jul 2013 06:56

Re: AccessViolationException when open an oracle connection

Post by zhuqijun » Wed 09 Mar 2016 04:33

Hello Shalex,

Thanks for your quick reply.

I would like to clarify one thing: in our application, each thread would have a OracleConnection instance, so it is not 'using the same OracleConnection in several threads at the same time'

As the issue occurs randomly, I cannot send you a small test project which can reproduce the issue stably

Do you have any chance to look into the information in my first post and provide any suggestion why it could happen?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: AccessViolationException when open an oracle connection

Post by Shalex » Wed 09 Mar 2016 11:53

Usually call stack doesn't help to identify the reason of AccessViolationException, because the issue occurs sometime before. A test project for reproducing is required for investigation.

You are using an outdated (7.7.276) provider version. Newer versions include fixes related to AccessViolationException (revision history page):
  • 8.4.191 26-Jun-14
    The bug with AccessViolationException when finalizing an open OracleDataReader in the OCI mode is fixed
  • 8.5.506 01-Oct-15
    The bug with the "OCI invalid handle" exception and AccessViolationException when disposing an OracleDependency object is fixed
  • 8.5.602 25-Feb-16
    The bug with an AccessViolationException when using a long password or user id is fixed
We recommed you to try the newest (8.5.602) build to check if the issue you have encountered has already been fixed. If you do not have access to the licensed v8.5.602, test the trial one.

Post Reply