System.AccessViolationException

8 posts, 0 answers
  1. Wolfgang
    Wolfgang avatar
    98 posts
    Member since:
    Oct 2012

    Posted 11 Sep 2013 Link to this post

    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()







  2. Ady
    Admin
    Ady avatar
    588 posts

    Posted 13 Sep 2013 Link to this post

    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.
  3. DevCraft banner
  4. Wolfgang
    Wolfgang avatar
    98 posts
    Member since:
    Oct 2012

    Posted 14 Sep 2013 Link to this post

    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

  5. Ady
    Admin
    Ady avatar
    588 posts

    Posted 18 Sep 2013 Link to this post

    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.
  6. Wolfgang
    Wolfgang avatar
    98 posts
    Member since:
    Oct 2012

    Posted 05 May 2015 in reply to Ady Link to this post

    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

  7. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 07 May 2015 Link to this post

    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.
     
  8. Wolfgang
    Wolfgang avatar
    98 posts
    Member since:
    Oct 2012

    Posted 24 Jun 2015 in reply to Thomas Link to this post

    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

  9. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 25 Jun 2015 Link to this post

    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.
Back to Top
DevCraft banner