Archived Forum Post

Index of archived forum posts


new Email() System.AccessVialationException v9.4.1 SP1

Feb 01 '14 at 17:23

Hi Chilkat, irregular crashes pop-up in constructor of Email class in v9.4.1 SP1 (ChilkatDotNet45.dll). It seems to be related to multithreaded usage.

Here is the exception message & stacktrace:

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

   at ClsEmail.createNewCls()
   at Chilkat.Email..ctor()
   at ChilkatCrashTest.Crasher.Crash() in c:\Source\My\ChilkatCrasher\ChilkatCrashTest\Crasher.cs:line 13
   at ChilkatCrashTest.Program.<Main>b__0(Crasher lCrasher) in c:\Source\My\ChilkatCrasher\ChilkatCrashTest\Program.cs:line 25
   at System.Threading.Tasks.Parallel.<>c__DisplayClassf`1.<ForWorker>b__c()
   at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
   at System.Threading.Tasks.Task.<>c__DisplayClass11.<ExecuteSelfReplicating>b__10(Object param0)
   at System.Threading.Tasks.Task.Execute()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
   at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()

The problem can be reproduced (appears NOT always, but with little patience [5-10 runs]) with following "brute-force" code:

class Program
    static void Main(string[] args)
        List<Crasher> lList = new List<Crasher>();
        for (int i = 0; i < 10; i++)
            lList.Add(new Crasher());

        ParallelOptions lOptions = new ParallelOptions();
        lOptions.MaxDegreeOfParallelism = System.Environment.ProcessorCount;
        Parallel.ForEach<Crasher>(lList, lOptions, lCrasher =>
            for (int i = 0; i < 100000; i++)

public class Crasher
    public void Crash()
        Chilkat.Email lEmail = new Chilkat.Email();

In reality it appears one time a month and crashes whole service process. :-(

Any idea?