nunit-core team mailing list archive
-
nunit-core team
-
Mailing list archive
-
Message #00370
Re: [Bug 558522] [NEW] Static std::string in C++/C# Mixed Project
Hi Christopher
The immediate thing that comes to my mind is that managd memory is trying to
access unmanaged memory but your input that if it is non-static it works
leaves the former point irrelevant. I thought I would point the unmanaged
aspect of it just in case if it helps you. I will try to work out with the
archive and let you know. It looks like a shared memory or process isolation
problem to me. Can you check the Tools->Settings in NUnit for Assembly
Isolation under "Test Loader"?
Jv
On Thu, Apr 8, 2010 at 10:03 PM, Christopher Santora
<chris.santora@xxxxxxx>wrote:
> Public bug reported:
>
> I encountered a couple strange errors when running unit tests in a C#
> project that references a C++/CLI project when using static std::strings. I
> don't know if it is related to NUnit, TestDriven.Net, or .Net itself, but it
> only happens when running a unit test; I cannot reproduce the problem in a
> C# console application or C# Windows application.
>
> I have attached a rar archive of a Solution that demonstrates the problem.
>
> The TestWeirdError project is a console application and has no problems.
> If I comment out line 15 of CppClassForWeirdError.h ("static std::string s
> ...") or change the string to not be static, then the NUnitTestForWeirdError
> project works fine, too.
> Otherwise, the NUnitTestForWeirdError project generates the following
> output:
>
>
> In Release Mode:
>
> TestCase 'NUnitTestForWeirdError.Class1.Test'
> failed: System.AccessViolationException : Attempted to read or write
> protected memory. This is often an indication that other memory is corrupt.
> f:\dd\vctools\crt_bld\self_x86\crt\src\msilexit.cpp(349,0): at
> _atexit_helper(IntPtr func, UInt32* __pexit_list_size, (fnptr)**
> __ponexitend, (fnptr)** __ponexitbegin)
> f:\dd\vctools\crt_bld\self_x86\crt\src\msilexit.cpp(520,0): at
> _atexit_m(IntPtr func)
> c:\users\administrator\documents\visual studio
> 2005\projects\testweirderror\cppclassforweirderror\cppclassforweirderror.h(15,0):
> at CppClassForWeirdError.CppClassForWeirdError..ctor()
> C:\Users\Administrator\Documents\Visual Studio
> 2005\Projects\TestWeirdError\NUnitTestForWeirdError\Class1.cs(14,0): at
> NUnitTestForWeirdError.Class1.Test()
>
>
> In Debug Mode:
>
> ---- DEBUG ASSERTION FAILED ----
> ---- Assert Short Message ----
> This function must be called in the default domain
> ---- Assert Long Message ----
>
> at <Module>._atexit_m(IntPtr func)
> f:\dd\vctools\crt_bld\self_x86\crt\src\msilexit.cpp(517)
> at CppClassForWeirdError..ctor()
> c:\users\administrator\documents\visual studio
> 2005\projects\testweirderror\cppclassforweirderror\cppclassforweirderror.h(15)
> at Class1.Test() C:\Users\Administrator\Documents\Visual Studio
> 2005\Projects\TestWeirdError\NUnitTestForWeirdError\Class1.cs(14)
> at RuntimeMethodHandle._InvokeMethodFast(Object target, Object[]
> arguments, SignatureStruct& sig, MethodAttributes methodAttributes,
> RuntimeTypeHandle typeOwner)
> at RuntimeMethodHandle.InvokeMethodFast(Object target, Object[]
> arguments, Signature sig, MethodAttributes methodAttributes,
> RuntimeTypeHandle typeOwner)
> at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder
> binder, Object[] parameters, CultureInfo culture, Boolean
> skipVisibilityChecks)
> at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder
> binder, Object[] parameters, CultureInfo culture)
> at Reflect.InvokeMethod(MethodInfo method, Object fixture, Object[]
> args)
> at TestMethod.RunTestMethod(TestCaseResult testResult)
> at TestMethod.doTestCase(TestCaseResult testResult)
> at TestMethod.doRun(TestCaseResult testResult)
> at TestMethod.Run(TestCaseResult testResult)
> at NUnitTestMethod.Run(TestCaseResult testResult)
> at TestCase.Run(EventListener listener)
> at TestCase.Run(EventListener listener, ITestFilter filter)
> at TestSuite.RunAllTests(TestSuiteResult suiteResult, EventListener
> listener, ITestFilter filter)
> at TestSuite.Run(EventListener listener, ITestFilter filter)
> at TestFixture.Run(EventListener listener, ITestFilter filter)
> at TestSuite.RunAllTests(TestSuiteResult suiteResult, EventListener
> listener, ITestFilter filter)
> at TestSuite.Run(EventListener listener, ITestFilter filter)
> at TestSuite.RunAllTests(TestSuiteResult suiteResult, EventListener
> listener, ITestFilter filter)
> at TestSuite.Run(EventListener listener, ITestFilter filter)
> at NUnitTestRunner.run(ITestListener testListener, Assembly assembly,
> ITestFilter filter)
> at NUnitTestRunner.runMethod(ITestListener testListener, Assembly
> assembly, MethodInfo method)
> at NUnitTestRunner.RunMember(ITestListener testListener, Assembly
> assembly, MemberInfo member)
> at AdaptorTestRunner.Run(ITestListener testListener, ITraceListener
> traceListener, String assemblyPath, String testPath)
> at Runner.Run()
> at ThreadHelper.ThreadStart_Context(Object state)
> at ExecutionContext.Run(ExecutionContext executionContext,
> ContextCallback callback, Object state)
> at ThreadHelper.ThreadStart()
> TestCase 'NUnitTestForWeirdError.Class1.Test'
> failed: System.AccessViolationException : Attempted to read or write
> protected memory. This is often an indication that other memory is corrupt.
> f:\dd\vctools\crt_bld\self_x86\crt\src\msilexit.cpp(349,0): at
> _atexit_helper(IntPtr func, UInt32* __pexit_list_size, (fnptr)**
> __ponexitend, (fnptr)** __ponexitbegin)
> f:\dd\vctools\crt_bld\self_x86\crt\src\msilexit.cpp(520,0): at
> _atexit_m(IntPtr func)
> c:\users\administrator\documents\visual studio
> 2005\projects\testweirderror\cppclassforweirderror\cppclassforweirderror.h(15,0):
> at CppClassForWeirdError.CppClassForWeirdError..ctor()
> C:\Users\Administrator\Documents\Visual Studio
> 2005\Projects\TestWeirdError\NUnitTestForWeirdError\Class1.cs(14,0): at
> NUnitTestForWeirdError.Class1.Test()
>
> ** Affects: nunitv2
> Importance: Undecided
> Status: New
>
> --
> Static std::string in C++/C# Mixed Project
> https://bugs.launchpad.net/bugs/558522
> You received this bug notification because you are a member of NUnit
> Developers, which is subscribed to NUnit V2.
>
> Status in NUnit V2 Test Framework: New
>
> Bug description:
> I encountered a couple strange errors when running unit tests in a C#
> project that references a C++/CLI project when using static std::strings. I
> don't know if it is related to NUnit, TestDriven.Net, or .Net itself, but it
> only happens when running a unit test; I cannot reproduce the problem in a
> C# console application or C# Windows application.
>
> I have attached a rar archive of a Solution that demonstrates the problem.
>
> The TestWeirdError project is a console application and has no problems.
> If I comment out line 15 of CppClassForWeirdError.h ("static std::string s
> ...") or change the string to not be static, then the NUnitTestForWeirdError
> project works fine, too.
> Otherwise, the NUnitTestForWeirdError project generates the following
> output:
>
>
> In Release Mode:
>
> TestCase 'NUnitTestForWeirdError.Class1.Test'
> failed: System.AccessViolationException : Attempted to read or write
> protected memory. This is often an indication that other memory is corrupt.
> f:\dd\vctools\crt_bld\self_x86\crt\src\msilexit.cpp(349,0): at
> _atexit_helper(IntPtr func, UInt32* __pexit_list_size, (fnptr)**
> __ponexitend, (fnptr)** __ponexitbegin)
> f:\dd\vctools\crt_bld\self_x86\crt\src\msilexit.cpp(520,0): at
> _atexit_m(IntPtr func)
> c:\users\administrator\documents\visual studio
> 2005\projects\testweirderror\cppclassforweirderror\cppclassforweirderror.h(15,0):
> at CppClassForWeirdError.CppClassForWeirdError..ctor()
> C:\Users\Administrator\Documents\Visual Studio
> 2005\Projects\TestWeirdError\NUnitTestForWeirdError\Class1.cs(14,0): at
> NUnitTestForWeirdError.Class1.Test()
>
>
> In Debug Mode:
>
> ---- DEBUG ASSERTION FAILED ----
> ---- Assert Short Message ----
> This function must be called in the default domain
> ---- Assert Long Message ----
>
> at <Module>._atexit_m(IntPtr func)
> f:\dd\vctools\crt_bld\self_x86\crt\src\msilexit.cpp(517)
> at CppClassForWeirdError..ctor()
> c:\users\administrator\documents\visual studio
> 2005\projects\testweirderror\cppclassforweirderror\cppclassforweirderror.h(15)
> at Class1.Test() C:\Users\Administrator\Documents\Visual Studio
> 2005\Projects\TestWeirdError\NUnitTestForWeirdError\Class1.cs(14)
> at RuntimeMethodHandle._InvokeMethodFast(Object target, Object[]
> arguments, SignatureStruct& sig, MethodAttributes methodAttributes,
> RuntimeTypeHandle typeOwner)
> at RuntimeMethodHandle.InvokeMethodFast(Object target, Object[]
> arguments, Signature sig, MethodAttributes methodAttributes,
> RuntimeTypeHandle typeOwner)
> at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder
> binder, Object[] parameters, CultureInfo culture, Boolean
> skipVisibilityChecks)
> at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder
> binder, Object[] parameters, CultureInfo culture)
> at Reflect.InvokeMethod(MethodInfo method, Object fixture, Object[]
> args)
> at TestMethod.RunTestMethod(TestCaseResult testResult)
> at TestMethod.doTestCase(TestCaseResult testResult)
> at TestMethod.doRun(TestCaseResult testResult)
> at TestMethod.Run(TestCaseResult testResult)
> at NUnitTestMethod.Run(TestCaseResult testResult)
> at TestCase.Run(EventListener listener)
> at TestCase.Run(EventListener listener, ITestFilter filter)
> at TestSuite.RunAllTests(TestSuiteResult suiteResult, EventListener
> listener, ITestFilter filter)
> at TestSuite.Run(EventListener listener, ITestFilter filter)
> at TestFixture.Run(EventListener listener, ITestFilter filter)
> at TestSuite.RunAllTests(TestSuiteResult suiteResult, EventListener
> listener, ITestFilter filter)
> at TestSuite.Run(EventListener listener, ITestFilter filter)
> at TestSuite.RunAllTests(TestSuiteResult suiteResult, EventListener
> listener, ITestFilter filter)
> at TestSuite.Run(EventListener listener, ITestFilter filter)
> at NUnitTestRunner.run(ITestListener testListener, Assembly assembly,
> ITestFilter filter)
> at NUnitTestRunner.runMethod(ITestListener testListener, Assembly
> assembly, MethodInfo method)
> at NUnitTestRunner.RunMember(ITestListener testListener, Assembly
> assembly, MemberInfo member)
> at AdaptorTestRunner.Run(ITestListener testListener, ITraceListener
> traceListener, String assemblyPath, String testPath)
> at Runner.Run()
> at ThreadHelper.ThreadStart_Context(Object state)
> at ExecutionContext.Run(ExecutionContext executionContext,
> ContextCallback callback, Object state)
> at ThreadHelper.ThreadStart()
> TestCase 'NUnitTestForWeirdError.Class1.Test'
> failed: System.AccessViolationException : Attempted to read or write
> protected memory. This is often an indication that other memory is corrupt.
> f:\dd\vctools\crt_bld\self_x86\crt\src\msilexit.cpp(349,0): at
> _atexit_helper(IntPtr func, UInt32* __pexit_list_size, (fnptr)**
> __ponexitend, (fnptr)** __ponexitbegin)
> f:\dd\vctools\crt_bld\self_x86\crt\src\msilexit.cpp(520,0): at
> _atexit_m(IntPtr func)
> c:\users\administrator\documents\visual studio
> 2005\projects\testweirderror\cppclassforweirderror\cppclassforweirderror.h(15,0):
> at CppClassForWeirdError.CppClassForWeirdError..ctor()
> C:\Users\Administrator\Documents\Visual Studio
> 2005\Projects\TestWeirdError\NUnitTestForWeirdError\Class1.cs(14,0): at
> NUnitTestForWeirdError.Class1.Test()
>
>
>
--
Static std::string in C++/C# Mixed Project
https://bugs.launchpad.net/bugs/558522
You received this bug notification because you are a member of NUnit
Developers, which is subscribed to NUnit V2.
Status in NUnit V2 Test Framework: New
Bug description:
I encountered a couple strange errors when running unit tests in a C# project that references a C++/CLI project when using static std::strings. I don't know if it is related to NUnit, TestDriven.Net, or .Net itself, but it only happens when running a unit test; I cannot reproduce the problem in a C# console application or C# Windows application.
I have attached a rar archive of a Solution that demonstrates the problem.
The TestWeirdError project is a console application and has no problems.
If I comment out line 15 of CppClassForWeirdError.h ("static std::string s ...") or change the string to not be static, then the NUnitTestForWeirdError project works fine, too.
Otherwise, the NUnitTestForWeirdError project generates the following output:
In Release Mode:
TestCase 'NUnitTestForWeirdError.Class1.Test'
failed: System.AccessViolationException : Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
f:\dd\vctools\crt_bld\self_x86\crt\src\msilexit.cpp(349,0): at _atexit_helper(IntPtr func, UInt32* __pexit_list_size, (fnptr)** __ponexitend, (fnptr)** __ponexitbegin)
f:\dd\vctools\crt_bld\self_x86\crt\src\msilexit.cpp(520,0): at _atexit_m(IntPtr func)
c:\users\administrator\documents\visual studio 2005\projects\testweirderror\cppclassforweirderror\cppclassforweirderror.h(15,0): at CppClassForWeirdError.CppClassForWeirdError..ctor()
C:\Users\Administrator\Documents\Visual Studio 2005\Projects\TestWeirdError\NUnitTestForWeirdError\Class1.cs(14,0): at NUnitTestForWeirdError.Class1.Test()
In Debug Mode:
---- DEBUG ASSERTION FAILED ----
---- Assert Short Message ----
This function must be called in the default domain
---- Assert Long Message ----
at <Module>._atexit_m(IntPtr func) f:\dd\vctools\crt_bld\self_x86\crt\src\msilexit.cpp(517)
at CppClassForWeirdError..ctor() c:\users\administrator\documents\visual studio 2005\projects\testweirderror\cppclassforweirderror\cppclassforweirderror.h(15)
at Class1.Test() C:\Users\Administrator\Documents\Visual Studio 2005\Projects\TestWeirdError\NUnitTestForWeirdError\Class1.cs(14)
at RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Reflect.InvokeMethod(MethodInfo method, Object fixture, Object[] args)
at TestMethod.RunTestMethod(TestCaseResult testResult)
at TestMethod.doTestCase(TestCaseResult testResult)
at TestMethod.doRun(TestCaseResult testResult)
at TestMethod.Run(TestCaseResult testResult)
at NUnitTestMethod.Run(TestCaseResult testResult)
at TestCase.Run(EventListener listener)
at TestCase.Run(EventListener listener, ITestFilter filter)
at TestSuite.RunAllTests(TestSuiteResult suiteResult, EventListener listener, ITestFilter filter)
at TestSuite.Run(EventListener listener, ITestFilter filter)
at TestFixture.Run(EventListener listener, ITestFilter filter)
at TestSuite.RunAllTests(TestSuiteResult suiteResult, EventListener listener, ITestFilter filter)
at TestSuite.Run(EventListener listener, ITestFilter filter)
at TestSuite.RunAllTests(TestSuiteResult suiteResult, EventListener listener, ITestFilter filter)
at TestSuite.Run(EventListener listener, ITestFilter filter)
at NUnitTestRunner.run(ITestListener testListener, Assembly assembly, ITestFilter filter)
at NUnitTestRunner.runMethod(ITestListener testListener, Assembly assembly, MethodInfo method)
at NUnitTestRunner.RunMember(ITestListener testListener, Assembly assembly, MemberInfo member)
at AdaptorTestRunner.Run(ITestListener testListener, ITraceListener traceListener, String assemblyPath, String testPath)
at Runner.Run()
at ThreadHelper.ThreadStart_Context(Object state)
at ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at ThreadHelper.ThreadStart()
TestCase 'NUnitTestForWeirdError.Class1.Test'
failed: System.AccessViolationException : Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
f:\dd\vctools\crt_bld\self_x86\crt\src\msilexit.cpp(349,0): at _atexit_helper(IntPtr func, UInt32* __pexit_list_size, (fnptr)** __ponexitend, (fnptr)** __ponexitbegin)
f:\dd\vctools\crt_bld\self_x86\crt\src\msilexit.cpp(520,0): at _atexit_m(IntPtr func)
c:\users\administrator\documents\visual studio 2005\projects\testweirderror\cppclassforweirderror\cppclassforweirderror.h(15,0): at CppClassForWeirdError.CppClassForWeirdError..ctor()
C:\Users\Administrator\Documents\Visual Studio 2005\Projects\TestWeirdError\NUnitTestForWeirdError\Class1.cs(14,0): at NUnitTestForWeirdError.Class1.Test()
References