Unhandled Exception: System.AccessViolationException

Ranorex Studio, Spy, Recorder, and Driver.
tvu
Posts: 195
Joined: Tue Apr 07, 2015 10:47 pm

Unhandled Exception: System.AccessViolationException

Post by tvu » Fri Jul 15, 2016 5:43 pm

I keep getting this error when I run my project in Jenkins on my RunTime machines. Jenkins would run the EXE and immediately get this error.

Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

I would say it's reproducible rate of about 20%. I also had this issue on my local workstation using Ranorex Studio when I installed Ranorex 6.0, but has not reoccurred since Ranorex 6.0.1.

I tried to do a complete reinstall following these two posts: Configuration for the RunTime machine
  • Ranorex 6.0.1
  • Windows 7 SP 1
  • Internet Explorer 11
  • iOS 9.3
  • Ranorex Agent is running when Jenkins kick off the build

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Unhandled Exception: System.AccessViolationException

Post by Support Team » Tue Jul 19, 2016 7:27 am

Hi tvu,

I'm afraid this is a known issue in Ranorex 6.0.

It's likely that the issue will be fixed in the next bug fix release of Ranorex. Unfortunately, I can't give you detailed information about when this version will be released. This depends on various factors. Nevertheless, all reported bugs and feature requests are documented in the release notes, with every new version release of Ranorex.

Thank you for your understanding.

Sincerely,
Johannes

tvu
Posts: 195
Joined: Tue Apr 07, 2015 10:47 pm

Re: Unhandled Exception: System.AccessViolationException

Post by tvu » Mon Aug 08, 2016 9:55 pm

Thanks Johannes.

Is there a workaround for this? We run several long regression overnight and this issue is beginning to be a bottleneck.

We kick off our automation with Jenkins. I know this isn't the Jenkins forum, but is there a way to do some sort of Try/Catch mechanism in a Jenkins Windows Batch Command? Basically, if it see this exception then kill the process and try again.

Thanks.

afleitas
Certified Professional
Certified Professional
Posts: 26
Joined: Thu May 14, 2015 3:57 pm

Re: Unhandled Exception: System.AccessViolationException

Post by afleitas » Tue Aug 09, 2016 1:12 pm

Hey Tung,

Are you running this on a Win10 machine? Have you attempted to uncomment the elevated privileges code in the program.cs file?

Thanks, Andy
Normal people... believe that if it ain't broke, don't fix it. Engineers believe that if it ain't broke, it doesn't have enough features yet.
-Scott Adams :)

tvu
Posts: 195
Joined: Tue Apr 07, 2015 10:47 pm

Re: Unhandled Exception: System.AccessViolationException

Post by tvu » Tue Aug 09, 2016 5:27 pm

Hi Andy,

I am developing on a Win 8 machine, but my Jenkins run time machines are Win7. No, I haven't modify program.cs in any way.

Thanks.

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Unhandled Exception: System.AccessViolationException

Post by krstcs » Tue Aug 09, 2016 5:45 pm

Since Johannes said that this will be fixed in the next bug release (6.0.2) I would guess that there isn't a workaround for it.

Going by their normal schedule (which could change, and I'm not privy to the internal information!!) 6.0.2 should be right around the corner, maybe withing the next week or two (hopefully??).

You might email them directly to see if there is any other information they can release.


As for Jenkins, if you are running the tests through the "Windows Batch Command" handler, you can do a DOS IF command. The Ranorex test returns a 0 if it is successful, -1 otherwise, so you can check for NOT 0 and rerun the test.

Code: Select all

myTest.exe
IF NOT %ERRORLEVEL%==0 myTest.exe
Shortcuts usually aren't...

tvu
Posts: 195
Joined: Tue Apr 07, 2015 10:47 pm

Re: Unhandled Exception: System.AccessViolationException

Post by tvu » Tue Aug 09, 2016 5:48 pm

Thanks krstcs! This is a big help.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Unhandled Exception: System.AccessViolationException

Post by Support Team » Wed Aug 10, 2016 3:19 pm

Hi tvu,

I'm afraid to tell you that there is currently no way to work around this issue.

Unfortunately, this bug fix won't be released in the next bug fix version, but it's likely that it will be contained in Ranorex 6.1.0, which will be released after 6.0.2.

We apologize for any inconvenience.

Sincerely,
Johannes

tvu
Posts: 195
Joined: Tue Apr 07, 2015 10:47 pm

Re: Unhandled Exception: System.AccessViolationException

Post by tvu » Wed Aug 10, 2016 7:14 pm

Thanks Johannes for the update. For the time being, I am following krstcs' suggestion and doing the following:

Code: Select all

myTest.exe

:: Setting parameter to test if the automation completed without any unknown error
set runResult=FALSE

:: Automation completed and all test cases passed
if %ERRORLEVEL% == 0 (
   set runResult=TRUE
)

:: Automation completed, but had failed test cases
if %ERRORLEVEL% == -1 (
   set runResult=TRUE
)

:: Re-run if some other error occurred
if %runResult% == FALSE (
    myTest.exe
)
This doesn't stop the error from happening on the second attempt to execute myTest.exe, but it at least guarantees that it will try again if the unhandled exception occurs.

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Unhandled Exception: System.AccessViolationException

Post by krstcs » Wed Aug 10, 2016 8:34 pm

There is also a plugin for Jenkins that allows you to specify the number of times to retry a job on failure.

https://wiki.jenkins-ci.org/display/JEN ... tor+Plugin


Might should have thought of that earlier... :D
Shortcuts usually aren't...

tvu
Posts: 195
Joined: Tue Apr 07, 2015 10:47 pm

Re: Unhandled Exception: System.AccessViolationException

Post by tvu » Wed Aug 10, 2016 8:46 pm

Thanks krstcs!

Have you tried it?

Does it let you re-run a build base on ERRORLEVEL? The ERRORLEVEL == 0 || -1 are validate values of a successful test suite run. When you get a -1, it's reported as a build failure, but I wouldn't want to re-run the whole suite.

Additionally, this might be useful to have it re-run only failed test cases.

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Unhandled Exception: System.AccessViolationException

Post by krstcs » Wed Aug 10, 2016 8:57 pm

Yes, I have tried it, and it works great if you just want to rerun a test a couple of times if it fails.

However, it might not work for what you need unless you change your job's batch to return an error code back to Jenkins only if you get the exception, which is probably not what you want.

So, I would stay with what you have. I just wanted to throw it out there in case it helped.
Shortcuts usually aren't...

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Unhandled Exception: System.AccessViolationException

Post by odklizec » Wed Aug 10, 2016 9:41 pm

Hi,

I'm personally using a combination of Naginator plugin suggested by Kelly and Log Parser plugin, which can be configured to analyse the console output. In case there is found a defined text, it can set the job as unstable/failed. And then the Naginator restarts the unstable/failed job ;) This way you don't have to use return values and possibly unreliable batch commands (if not properly configured).
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

tvu
Posts: 195
Joined: Tue Apr 07, 2015 10:47 pm

Re: Unhandled Exception: System.AccessViolationException

Post by tvu » Wed Aug 10, 2016 10:28 pm

Thanks odklizec.

I'm curious on how you guys have things setup.

For an iOS build regression, I would run a single long running test suite that runs through all my test cases on a single mobile device. I run several of these in parallel for different devices. Each test suite / mobile device combination will run on a separate run time machine.

I use the iOS app to validate a server release as well. These long running test suites isn't the ideal setup though. My manager insist on running through all the test cases so it would take several hours before I can get the results.

I would like to split the test suite into smaller run configurations. Each unique run configuration would run in parallel on a different mobile device. The idea is to get the results in less than 30 minutes by splitting it up. Unfortunately, there isn't a way to combine the reports and I don't want to spam everyone with multiple reports.

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Unhandled Exception: System.AccessViolationException

Post by krstcs » Thu Aug 11, 2016 2:34 pm

I don't show my Ranorex reports to anyone but my direct supervisor, and then only when he asks (which isn't very often!! :D ). My QA director doesn't want to see them, the manual testers just want to know if it passed or failed, and the devs just want to know why it's broken if it fails.

So I have my tests all report their final status to my DB (all my data is in SQL Server) and I have a dashboard build in MS Lightswitch HTML that anyone can use to look at actual scenario results, manage data sets, and queue Jenkins jobs.


Note: My tests are VERY dynamic, in that certain test cases do or don't run based on what the current scenario/data set requires. I manipulate the SQL data connectors at runtime to force the queries (I use stored procedures for everything) to bring back just the data for this particular scenario and test case combination. For instance, my testing is against our Point-of-Sale (POS) system. So each scenario is a collection of transactions that are all related (for example: purchase something -> fulfill the purchase -> return a part, is one scenario). So, at the end of each transaction, I report to the DB and then aggregate all the transactions in each scenario.

For Jenkins this means that I also have some very specialized Groovy scripts that collate data to make sure the job starts the right set of store/AUT combinations. And then I pass that info to Ranorex so it knows what test scenarios to run in any given configuration.



** I'm in the process of rewriting much of this right now because the dev team has moved to TeamCity and we are being told to do that as well so everything is integrated. TC doesn't do things the same way as Jenkins, so if we go through with this I basically will have to recreate much of the Jenkins server-agent architecture. It's a pain to retool, but I love the development side, so I'm having a blast! :D



Edit for grammar
Last edited by krstcs on Thu Aug 11, 2016 9:13 pm, edited 1 time in total.
Shortcuts usually aren't...