This is a migrated thread and some comments may be shown as answers.

System.AccessViolationException

7 Answers 59 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Wolfgang
Top achievements
Rank 1
Wolfgang asked on 11 Sep 2013, 02:57 PM
Hi,

don't know how to write it, but... 

if i add specific elements to an objectscope and do a commit i get an System.AccessViolationException .

This is very. weird. I removed the application specific parts (Table name and fields) from the error message, here is the rest:

Can you help?

Best regards,
Wolfgang

Telerik.OpenAccess.Exceptions.DataStoreException: Insert of '174289506-3a218f06-c2b4-4b50-96d9-cbd8d28ce4ba' failed: System.AccessViolationException: Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein Hinweis darauf, dass anderer Speicher beschädigt ist.
 
   bei Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute()
 
   bei OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute()
 
   bei OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes)
INSERT INTO "TABLE" (A_FEW_FIELDS) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
(set event logging to all to see parameter values) System.AccessViolationException: Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein Hinweis darauf, dass anderer Speicher beschädigt ist.
 
   bei Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute()
 
   bei OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute()
 
   bei OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes) ---> System.AccessViolationException: Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein Hinweis darauf, dass anderer Speicher beschädigt ist.
 
   bei Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute()
 
   bei OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute()
 
   bei OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes)
 
   --- Ende der internen Ausnahmestapelüberwachung ---
 
   bei Telerik.OpenAccess.SPI.Backends.ThrowException(Exception e)
 
   bei OpenAccessRuntime.ExceptionWrapper.Throw()
 
   bei OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.handleException(Exception x, Boolean needsRollback)
 
   bei OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.internalCommit(Boolean phase)
 
   bei OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.commit()
 
   bei OpenAccessRuntime.DataObjects.SynchronizedPMProxy.commit()
 
   bei OpenAccessRuntime.TransactionImpl.Commit()
 
   bei ...
   bei ...
 
   bei ...
 
   bei ...
 
   bei OpenAccessRuntime.ExceptionWrapper.Throw()
 
   bei OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.handleException(Exception x, Boolean needsRollback)
 
   bei OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.internalCommit(Boolean phase)
 
   bei OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.commit()
 
   bei OpenAccessRuntime.DataObjects.SynchronizedPMProxy.commit()
 
   bei OpenAccessRuntime.TransactionImpl.Commit()







7 Answers, 1 is accepted

Sort by
0
Ady
Telerik team
answered on 13 Sep 2013, 01:30 PM
Hello Wolfgang,

 This is indeed weird. Can you provide some more information about the data/class that causes this exception? What is the class mapping, does it have references etc.
I would need some more information about your model and calling code.

Looking forward to your reply.

Regards,
Ady
Telerik
OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
0
Wolfgang
Top achievements
Rank 1
answered on 14 Sep 2013, 06:44 AM

Hi,

The table wurde the exception finally happens has the folliwing form

Guid as UID, mapping to foreign table, literally dozends of strings translated in multiple Strings.

The insert if an element is eine which inserts the element where the exception occurs on third Level, for complete insert of the element tree 18 objects See added to objectscope. ( it should not be a problem with numbers of objects, as we sometimes insert a lot of more data in one commit where objects belobg together)

Best regards

Wolfgang

0
Ady
Telerik team
answered on 18 Sep 2013, 02:35 PM
Hi Wolfgang,

 Unfortunately this doesn't help me in reproducing the problem. Can you provide me the model or at least part of the model that I can use to try and reproduce the exception.? Also you could send the calling code - how you are creating the instances and adding them to the scope.

Regards,
Ady
Telerik
OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
0
Wolfgang
Top achievements
Rank 1
answered on 05 May 2015, 11:35 AM

Hi Ady, 

 After it was quit for some time the problem occured again.

 The bad thing was that it seems that data was lost in this case. 

PO anObject = new PO();

... 

this.objectScope.Database.Cache.EvictAll();
if (!this.objectScope.Transaction.IsActive)
this.objectScope.Transaction.Begin();

this.objectScope.Add(anObject);

...

if (objectScope.Transaction.IsActive)
this.objectScope.Transaction.Commit();

 

Can you tell me what to do to solve the problem?

 The exception seems to hapen at commit, other objects which are not transmitted seems to get lost.

Regards

Wolfgang

0
Thomas
Telerik team
answered on 07 May 2015, 12:52 PM
Hi Wolfgang,

I know this issue from clients using Oracle databases. The problem often was not the database itself, but rather the ADO driver used to access it. Can you check the version and see if you had the newest version installed? Oracle uses lots of unmanaged code and the AccessViolationException is often thrown when there is a mismatch between the native Oracle Client and the ADO.NET driver using it.
You might also want to give the purely managed Oracle driver a chance, which in turn avoids these kind of issues completely.

Regards,
Thomas
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
0
Wolfgang
Top achievements
Rank 1
answered on 24 Jun 2015, 02:09 PM

Hi Thomas,

 problem happened again - it is a Sybase 12 DataBase, not an Oracle one.

 

>Telerik.OpenAccess.Exceptions.DataStoreException: Insert of '...' failed: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute(Nullable`1 commandTimeout)
  at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute(Nullable`1 commandTimeout)
  at OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes, BatchControlInfo batchControl)
INSERT INTO class (fields) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
(set event logging to all to see parameter values) System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute(Nullable`1 commandTimeout)
  at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute(Nullable`1 commandTimeout)
  at OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes, BatchControlInfo batchControl) ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute(Nullable`1 commandTimeout)
  at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute(Nullable`1 commandTimeout)
  at OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes, BatchControlInfo batchControl)
  --- End of inner exception stack trace ---
  at OpenAccessRuntime.ExceptionWrapper.Throw()
  at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.handleException(Exception x, Boolean needsRollback)
  at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.internalCommit(Boolean phase)
  at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.commit()
  at OpenAccessRuntime.DataObjects.SynchronizedPMProxy.commit()

 I'm still abit clueless in which situation it occurs - it's normally not reproducable.

Best regards

Wolfgang

0
Thomas
Telerik team
answered on 25 Jun 2015, 02:10 PM
Hello Wolfgang,

from what I know, this exception is thrown when the CLR runtime wants to allocate/deallocate some memory from/to the C runtime system, or maybe from/to the Operating System itself. If at this moment it detects a memory corruption, this exception is thrown. As the message indicates, the actual corruption might have happened any time before, but was unnoticed then.
DataAccess neither uses unmanaged code, nor is it implementing unsafe methods: We do not access memory in any other way that through the managed CLR.
So far I got such reports only from processes, where an assembly used unmanaged (or unsafe) code. This happened randomly with Oracle (as it uses a unmanaged .dll for some functionality), but the managed Oracle driver did not show such behavior. When Sybase is now showing the symptoms, I strongly suspect a managed/unmanaged mismatch there too OR a problem with the C runtime system that is used by the unmanaged code. Can you check (with debugger) which msvcrt assemblies are loaded in such a case in the process? Also: Are you using System.Transactions (because this is also often using unmanaged code)?

Again, I do not see a chance that we are directly responsible for this. 

Regards,
Thomas
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
Tags
General Discussions
Asked by
Wolfgang
Top achievements
Rank 1
Answers by
Ady
Telerik team
Wolfgang
Top achievements
Rank 1
Thomas
Telerik team
Share this question
or