AccessViolationException with SDO polygons

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
woehling
Posts: 5
Joined: Sun 26 Jul 2009 16:23

AccessViolationException with SDO polygons

Post by woehling » Thu 21 Jul 2011 16:19

Hi,

I get an System.AccessViolationException when using the OracleObject data type. I'm working with SDO_GEOMETRY objects, the column contains POLYGON geometries or NULL.

I tried this out on Vista x86 and Win7 x64, with dotConnect Express (latest version, v6.30.185 and also older versions from 2011), Oracle Client 11.2.0.1 32bit, Oracle Server 11.1.0.6 64bit). Target platform is .NET 4 (x86), but the problem also exists in .NET 2.

I first thought it would be a .NET 4 problem, because older versions of our product are working fine. But then I tried dotConnect Express v5.25.49.0: With this version everything works fine!
So there is definitely a problem in your code. I also tried out ODP.NET: no problems at all.

This is the StackTrace:
OciDynamicType.nativeOCIObjectFree(HandleRef , HandleRef , HandleRef , In
t16 )
OciDynamicType.OCIObjectFree(HandleRef , HandleRef , HandleRef , Int16 )
Devart.Data.Oracle.h.a(IntPtr A_0)
Devart.Data.Oracle.ab.l()
Devart.Data.Oracle.ab.c(Int32 A_0)
Devart.Data.Oracle.ab.b(Int32 A_0)
Devart.Data.Oracle.OracleDataReader.Read()

I was not able to reproduce the behavior with newly created data, but this is a small piece of code that throws the exception (but only with my data):

Code: Select all

    var sql = "select GEOMETRY from ...";
    var reader = ...;
    while(reader.Read())
    //Read() throws at same position every time. Slightly changing the sql statement slightly changes the position too...
    {
        object sdo = reader[0];
    }
I managed to work around the problem, because I changed the sql statement to:
var sql = "select CASE WHEN GEOMETRY IS NULL THEN SDO_UTIL.FROM_WKTGEOMETRY('POINT (0 0)') ELSE GEOMETRY END from ...";

With this statement also no exception:
var sql = "select GEOMETRY from ... where NOT GEOMETRY IS NULL";

So I assume that there is a memory management problem in the dotConnect provider. The last sdo object seemed to be corrupt, because the debugger showed "a mess" sometimes when I "looked into" the sdo object.
So the NULL values seem to be the cause for this problem.
Note: The GEOMETRY column is often NULL because the table is LEFT JOINed (so no matching record exists in the GEOMETRY column's table)

Hope you can fix this!

Regards,
Markus

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

Post by Shalex » Mon 25 Jul 2011 10:08

Could you please send us a small test project with the DDL/DML script (with your data)? We cannot reproduce the problem with the following code in our environment using dotConnect for Oracle v 6.30.185:

Code: Select all

DDL/DML:
CREATE TABLE cola_markets (
  mkt_id NUMBER PRIMARY KEY,
  name VARCHAR2(32),
  shape SDO_GEOMETRY);
INSERT INTO cola_markets VALUES(
  1,
  'cola_a',
  SDO_GEOMETRY(
    2003,  -- two-dimensional polygon
    NULL,
    NULL,
    SDO_ELEM_INFO_ARRAY(1,1003,3), -- one rectangle (1003 = exterior)
    SDO_ORDINATE_ARRAY(1,1, 5,7)
  )
);
INSERT INTO cola_markets VALUES(
  2,
  'cola_b',
  null
);

C#:
    var sql = "select shape from cola_markets";
    using (OracleConnection conn = new OracleConnection()){
        conn.ConnectionString = "server=orcl1120;uid=***;pwd=***;";
        conn.Open();
        OracleCommand cmd = conn.CreateCommand();
        cmd.CommandText = sql;
        var reader = cmd.ExecuteReader();
        while(reader.Read()){
            object sdo = reader[0];
        }
    }

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

Post by Shalex » Wed 27 Jul 2011 16:00

Please try changing the value of OracleCommand.FetchSize property in your code to solve the issue.
We will investigate the difference in behaviour of dotConnect for Oracle v 5.25.49 and 6.30.185.

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

Post by Shalex » Thu 29 Sep 2011 15:00

The bug with reading Oracle Objects via OracleDataReader is fixed. We will post here when the corresponding build of dotConnect for Oracle is available for download.

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

Post by Shalex » Tue 25 Oct 2011 08:34

New build of dotConnect for Oracle 6.50.237 is available for download now!
It can be downloaded from http://www.devart.com/dotconnect/oracle/download.html (trial version) or from Registered Users' Area (for users with valid subscription only). It includes the mentioned fix.
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=22379 .

Post Reply