Sybase: Attempted to read or write protected memory

Posts   
 
    
troyb
User
Posts: 16
Joined: 14-Mar-2007
# Posted on: 01-Sep-2009 00:31:20   

Version 2.5 June 2nd 2008 (v2.0.50727 runtime ver) Sybase.Data.AseClient 1.15.152.0

When trying to insert a column into a table with a "text" field I get the following exception...

System.AccessViolationException was caught Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt." Source="Sybase.Data.AseClient" StackTrace: at ᜀ.ᜀ(IntPtr A_0, IntPtr A_1) at Sybase.Data.AseClient.AseCommand.ᜀ(Boolean A_0) at Sybase.Data.AseClient.AseCommand.ᜁ(Boolean A_0) at Sybase.Data.AseClient.AseCommand.ᜅ() at Sybase.Data.AseClient.AseCommand.Dispose(Boolean disposing) at System.ComponentModel.Component.Dispose() at SD.LLBLGen.Pro.ORMSupportClasses.Query.Dispose(Boolean isDisposing) at SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Dispose(Boolean isDisposing) at SD.LLBLGen.Pro.ORMSupportClasses.Query.Dispose() at SD.LLBLGen.Pro.ORMSupportClasses.BatchActionQuery.Dispose(Boolean isDisposing) at SD.LLBLGen.Pro.ORMSupportClasses.BatchActionQuery.Dispose() at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.PersistQueue(List`1 queueToPersist, Boolean insertActions, Int32& totalAmountSaved) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave, IPredicateExpression updateRestriction, Boolean recurse) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.SaveEntity(IEntity2 entityToSave) at Phase3Messaging.Form1.button3_Click(Object sender, EventArgs e) in C:\work\1cid\src\2cmm\Phase3Messaging\Phase3Messaging\Form1.cs:line 417 InnerException:

Here's the code...

            P3ConnectionErrorsEntity logerror = new P3ConnectionErrorsEntity();
            logerror.MsgSource = "The Source";
            logerror.MsgShortText = "The Short Text";
            logerror.MsgLongText = "The Long long long long Long long long long Long long long long Long long long long Long long long long text";

            try
            {
                // Now add the new log error to the Database...
                using (DataAccessAdapter adapter = new DataAccessAdapter(AppConfiguration.DBConnectionString))
                {
                    adapter.SaveEntity(logerror);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

Here's the Table DDL...


CREATE TABLE dbo.P3ConnectionErrors ( 
    msgSeq      numeric(18,0) IDENTITY NOT NULL,
    msgDateTime     datetime DEFAULT GETDATE() NOT NULL,
    msgSource       varchar(20) NOT NULL,
    msgShortText    varchar(255) NOT NULL,
    msgLongText     text NULL 
    )

If I do not set the logerror.MsgLongText (text) field, the insert succeeds.

It looks like something with cleaning up unmanaged resources, I know you are all shocked that Sybase data provider would have bugs.stuck_out_tongue_winking_eye

Anyway, is this similar to the OleDB issure resolved here...

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=14061&HighLight=1

Maybe through the magic of LLBLGen a work around could be provided?

Thanks!

Troy

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 01-Sep-2009 04:30:53   

HI Troy,

The error comes from AseClient provider side. I think this is related to your previos thread (http://llblgen.com/TinyForum/Messages.aspx?ThreadID=15670). Did you contact Sybase on this matter?

Should be solvable from Sybase, IMHO. See this for instance: http://llblgen.com/TinyForum/Messages.aspx?ThreadID=13624

David Elizondo | LLBLGen Support Team
troyb
User
Posts: 16
Joined: 14-Mar-2007
# Posted on: 01-Sep-2009 11:42:30   

David,

Thanks for the response! I was able to resolve the error you refered to in the link.

This new excpetion does have the same error message, but a different call stack. It appears like an object is being disposed of twice, similar to the OleDB thread I had linked to. Was hoping it was something you guys could easily reproduce it and potentially have a work around for it! If not, I'll need to come up with another non text table structure.

I think we all know the response I'll get from Sybase wink

Thanks,

Troy

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39880
Joined: 17-Aug-2003
# Posted on: 01-Sep-2009 18:55:49   

We have 1.15.320 as ase driver dll version, so they have a newer version for you. Could you try that newer ASE provider dll first please? (it's from june 2008, so I think there's likely a newer that that one)

We also found another thread which could be related, which was about a bugfix in 2.6, (which caused the issue to pop up in ms access). Could you try the latest runtime libs from 2.5 as well ? (you posted the .net version number btw wink ). That error only occured in selfservicing btw, so it's likely not related...

Frans Bouma | Lead developer LLBLGen Pro
troyb
User
Posts: 16
Joined: 14-Mar-2007
# Posted on: 02-Sep-2009 19:23:33   

Thanks for the info on the ase driver, I was not aware of the new version. I'll get the latest versions and let you know how things work out

Thanks again!

Troy

troyb
User
Posts: 16
Joined: 14-Mar-2007
# Posted on: 03-Sep-2009 20:25:15   

Ok, upgraded to the AseClient (1.15.325.0), and LLBLGen 2.6 (2.6.09.0807)

Same error (different call stack) Looks to a Sybase issue (shocking) FWIW, here's the new exception info...

SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException was caught Message="An exception was caught during the execution of an action query: An exception was caught during the execution of a sequence retrieval query: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception." Source="SD.LLBLGen.Pro.ORMSupportClasses.NET20" RuntimeBuild="08072009" RuntimeVersion="2.6.0.0" QueryExecuted="\r\n\tQuery: INSERT INTO customer.dbo.P3ConnectionErrors (msgSource, msgShortText, msgLongText) VALUES (@MsgSource, @MsgShortText, @MsgLongText)\r\n\tParameter: @MsgSource : AnsiString. Length: 20. Precision: 0. Scale: 0. Direction: Input. Value: \"The Source\".\r\n\tParameter: @MsgShortText : AnsiString. Length: 255. Precision: 0. Scale: 0. Direction: Input. Value: \"The Short Text\".\r\n\tParameter: @MsgLongText : AnsiString. Length: 2147483647. Precision: 0. Scale: 0. Direction: Input. Value: \"The Long long long long Long long long long Long long long long Long long long long Long long long long text\".\r\n" StackTrace: at SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute() in c:\Myprojects\VS.NET Projects\LLBLGen Pro v2.0\RuntimeLibraries 2.6 .NET 2.x\ORMSupportClasses\Query\ActionQuery.cs:line 197 at SD.LLBLGen.Pro.ORMSupportClasses.BatchActionQuery.Execute() in c:\Myprojects\VS.NET Projects\LLBLGen Pro v2.0\RuntimeLibraries 2.6 .NET 2.x\ORMSupportClasses\Query\BatchActionQuery.cs:line 112 at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteActionQuery(IActionQuery queryToExecute) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v2.0\RuntimeLibraries 2.6 .NET 2.x\ORMSupportClasses\AdapterSpecific\DataAccessAdapterBase.cs:line 487 at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.PersistQueue(List`1 queueToPersist, Boolean insertActions, Int32& totalAmountSaved) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v2.0\RuntimeLibraries 2.6 .NET 2.x\ORMSupportClasses\AdapterSpecific\DataAccessAdapterBase.cs:line 1344 InnerException: SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException Message="An exception was caught during the execution of a sequence retrieval query: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception." Source="SD.LLBLGen.Pro.ORMSupportClasses.NET20" RuntimeBuild="08072009" RuntimeVersion="2.6.0.0" QueryExecuted="SELECT @@IDENTITY" StackTrace: at SD.LLBLGen.Pro.ORMSupportClasses.SequenceRetrievalQuery.Execute() in c:\Myprojects\VS.NET Projects\LLBLGen Pro v2.0\RuntimeLibraries 2.6 .NET 2.x\ORMSupportClasses\Query\SequenceRetrievalQuery.cs:line 159 at SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute() in c:\Myprojects\VS.NET Projects\LLBLGen Pro v2.0\RuntimeLibraries 2.6 .NET 2.x\ORMSupportClasses\Query\ActionQuery.cs:line 176 InnerException: System.AccessViolationException Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt." Source="Sybase.Data.AseClient" StackTrace: at Sybase.Data.AseClient.Unmanaged.ExecuteCommand(IntPtr pCommandHandle) at Sybase.Data.AseClient.AseCommand.Execute() at Sybase.Data.AseClient.AseCommand.ExecuteScalar() at SD.LLBLGen.Pro.ORMSupportClasses.SequenceRetrievalQuery.Execute() in c:\Myprojects\VS.NET Projects\LLBLGen Pro v2.0\RuntimeLibraries 2.6 .NET 2.x\ORMSupportClasses\Query\SequenceRetrievalQuery.cs:line 116 InnerException:

If I come across a fix from Sybase, I'll be sure to post it.

As always terrific support! Thanks again!

Troy

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39880
Joined: 17-Aug-2003
# Posted on: 07-Sep-2009 10:05:18   

Try at least to contact Sybase and ask for their response, even if it's 'we dunno, must be somebody elses fault'...

Frans Bouma | Lead developer LLBLGen Pro
kew98
User
Posts: 17
Joined: 23-Aug-2009
# Posted on: 09-Oct-2009 23:30:44   

I got the same error, when connecting Oracle 11g from .Net C# code

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

stack Trace: at System.Data.Common.UnsafeNativeMethods.OraMTSEnlCtxGet(Byte[] lpUname, Byte[] lpPsswd, Byte[] lpDbnam, OciHandle pOCISvc, OciHandle pOCIErr, UInt32 dwFlags, IntPtr& pCtxt) at System.Data.OracleClient.TracedNativeMethods.OraMTSEnlCtxGet(Byte[] userName, Byte[] password, Byte[] serverName, OciHandle pOCISvc, OciHandle pOCIErr, IntPtr& pCtxt) at System.Data.OracleClient.OciEnlistContext..ctor(Byte[] userName, Byte[] password, Byte[] serverName, OciServiceContextHandle serviceContextHandle, OciErrorHandle errorHandle) at System.Data.OracleClient.OracleInternalConnection.Enlist(String userName, String password, String serverName, Transaction transaction, Boolean manualEnlistment) at System.Data.OracleClient.OracleInternalConnection.Activate(Transaction transaction) at System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transaction transaction) at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.OracleClient.OracleConnection.Open() at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.OpenConnection() at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.PrepareQueryExecution(IQuery queryToExecute, Boolean forceConnectionSet) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteSingleRowRetrievalQuery(IRetrievalQuery queryToExecute, IEntityFields2 fieldsToFill, IFieldPersistenceInfo[] fieldsPersistenceInfo) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityUsingFilter(IEntityFields2 fieldsToFetch, IFieldPersistenceInfo[] persistenceInfos, IRelationPredicateBucket filter) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityUsingFilter(IEntity2 entityToFetch, IPrefetchPath2 prefetchPath, Context contextToUse, IRelationPredicateBucket filter, ExcludeIncludeFieldsList excludedIncludedFields) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityUsingUniqueConstraint(IEntity2 entityToFetch, IPredicateExpression uniqueConstraintFilter, IPrefetchPath2 prefetchPath, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityUsingUniqueConstraint(IEntity2 entityToFetch, IPredicateExpression uniqueConstraintFilter) at DataAccessService.GetGlobalParamValue(String ParamName) in c:\GVS\GVSWCFService\App_Code\Authorization.cs:line 104 at SyncInvokeGetGlobalParamValue(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 10-Oct-2009 03:43:12   
David Elizondo | LLBLGen Support Team