chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
hi, I've got a strange error.
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Error occurs occasionally and only on build machines. I've never reproduced one on developer's machine. Problem occurs maybe 1/5 of the time. Last error was thrown from the inner method (called by public method):

private void SomeMethod(List<IXXX> info)
        {
            lock (something)
            {
                foreach (IYYY provider in  ...)
                {
                   // nothing interesting (no IO, no registry, no db access...)
                }
            }
        }



I have searched high and low on the internet but there doesn't seem to be a definitive answer anywhere.

Config:
.net 2.0 + TM Isolator 5.4.2.0 + Win XP
asked by belial24 (720 points)

5 Answers

0 votes
Hi,

My guess is that problem is related to usage of multi threading in the test or in the code under test.
We have fixed few issues regarding multi threading in the Isolator since version 5.4.2.0.
Can you try to install the latest version (6.0.4) and see if it solves the problem?
answered by ohad (35.4k points)
0 votes
hi, thanks for the reply. i have to talk it over with my boss. probably we have to try your solution
answered by belial24 (720 points)
0 votes
Hi again,

we've switched onto Isolator 6.0.4. unfortunately we had problem yesterday. another System.AccessViolationException in unexpected place and time. we run test again and everything's ok. what to do now, what would you suggest?
answered by belial24 (720 points)
0 votes
Hi,

Do the same tests always fail? Do they ever fail if run alone, or only when run with all tests?

Can you post the code for one of the failing tests?

Thanks,
Doron
Typemock Support
answered by doron (17.2k points)
0 votes
we run all tests and the error occurs randomly for methods, projects...

here is the letest lucky one:
public override void StartService()
{
try
{
XXXTracer.Write("XXXX StartService.");
if (ServiceState == ServiceState.Started)
{
throw new ServiceAlreadyStartedException(Resources.ApplicationInfoAlreadyStarted);
}

ScanApplications();
ServiceState = ServiceState.Started;

}
catch (Exception ex)
{
ServiceState = ServiceState.Malfunction;
throw new Exception(Resources.ApplicationInfoStartingFailed, ex);
}
}

...
XXXTracer just uses TraceSource object and trace info
...
ServiceState is a simple property setter
....
Isolate.NonPublic.WhenCalled(service, "ScanApplications").IgnoreCall();
....
exception:
System.AccessViolationException : Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at XXX.YYY.StartService()
at XXX.YYY.ZZZ.CCCTests.ApplicationsProperty_ServiceStarted_EmptyApplicationList() in E:Test.cs:line 35
at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Boolean A_5, Object[] A_6)
at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected, Boolean isInterceptedType)
at
answered by belial24 (720 points)
...