Elvas Tower: Cannot access the file used by another process - Elvas Tower

Jump to content

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Cannot access the file used by another process How best to tackle? Rate Topic: -----

#1 User is offline   cjakeman 

  • Vice President
  • PipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 2,857
  • Joined: 03-May 11
  • Gender:Male
  • Location:Peterborough, UK
  • Simulator:Open Rails
  • Country:

Posted 03 June 2020 - 10:16 AM

I reported 3 cases in an earlier thread and received useful advice - thanks, guys.

We're now up to 5 reported cases since mid-May (no doubt many more unreported). I've collected log files but it's difficult to see a common pattern. I've saved the 5 cases in a spreadsheet.

  • The OS is both Windows 7 and Windows 10, both 32-bit and 64-bit, both Home and Pro.
  • The routes include Microsoft JAPAN1 and Demo Model 1, so nothing odd there.
  • The stack trace is at RunActivity\Viewer3D\Materials.cs:line 142 in 4/5 cases and line 152 in the other.
  • The only common element is that these are all Stable 1.3.1.4328
  • And the filename is of the form AppData\Local\Temp\tmpABCD.tmp where ABCD is a hexadecimal number.
  • One of the more experienced users reports that this happens sometimes but not always. No anti-virus in place.

I guess, like me, ET members here tend to use the Testing or Unstable versions rather than the Stable one so you may not have seen it yourselves.

Any thoughts on what can we can do to help these users?

#2 User is offline   Hamza97 

  • Engineer
  • Group: Status: Contributing Member
  • Posts: 606
  • Joined: 01-March 15
  • Gender:Male
  • Simulator:Open Rails
  • Country:

Posted 03 June 2020 - 06:49 PM

This has happened to many users here in our MSTS community ..., I would try getting log files of those if I can ..., The ONLY solution so far seems to be reinstalling Open Rails and keep AV OFF during playing .... :(

#3 User is offline   superheatedsteam 

  • Conductor
  • Group: Status: Contributing Member
  • Posts: 497
  • Joined: 28-June 08
  • Location:Perth, WA
  • Country:

Posted 03 June 2020 - 09:58 PM

View Postcjakeman, on 03 June 2020 - 10:16 AM, said:

Any thoughts on what can we can do to help these users?


The 'go to' program to capture file contention is Sysinternals Process Monitor and it's free.

Google search “Process Monitor” and download it only from the docs.microsoft.com site.

This is an executable program and does not install on the computer.

You have to be an administrator on the computer in order for Process Monitor to run.

I would suggest extracting the zip to C:\TEMP and run procmon.exe.

Process Monitor logs can get very large in a short order of time and it starts logging as soon as it starts. Click the 'Capture' (magnifying glass) button to stop the capture if it starts logging on start-up.

Use the 'File>Backing file' menu and change it from using 'virtual' to 'C:\TEMP\OR_LOGGING' or the path/filename of your choice and click on 'OK'.

Click on the 'Clear' speed button to clear the current capture.

Go to the 'Filter' menu and ensure 'Drop filtered events' has a tick next to it.

Use the 'Filter>Filter' menu and click on the 'Reset' button.

Find the tickbox for 'Process Name' 'is' 'System' and uncheck it.

Select the first dropdown that has the word 'Architecture' in it and select 'Path'.

Select the second dropdown that has the word 'is' in it and select 'contains'.

In the field next to that type in the path, or partial path to that users temp folder as recorded in the openrails.txt file e.g. AppData\Local\Temp\tmp

Click on the 'Add' button.

Click on the 'Apply' button.

Click on the 'OK' button.

Now when you click on the 'Capture' speed button so that there is no red cross in it. Process Monitor will start recording any access to files that contain the string entered in the filter.

With Process Monitor running and logging, go into OR and run it till the error is generated then go back to Process Monitor and click on the 'Capture' speed button to stop capture, a red cross appears over the magnifying glass.

Close Process Monitor.

The resultant C:\TEMP\OR_LOGGING.PML file may be large depending on how much activity there was. The PML files compress well when zipped.

These can be opened on another computer that has Process Monitor on it.

Use the filters (they are non destructive) in Process Monitor to refine the view and observe what processes are accessing the file in question and find the point where the file contention occurred. Instead of a 'SUCCESS' result you should see a ACCESS DENIED, NOT GRANTED, SHARING VIOLATION or similar message. From that point, go back up the log and see what other processes were accessing file file prior to the file contention. If OR is accessing the file, see if the process closed the file before attempting to access it again (CREATE FILE) with a different level of file access. Double clicking the event will bring up the details information in a more structured display which may help.

Note, if you click on the 'Capture' button again you will be prompted to confirm you wish to overwrite the previous log. Process Monitor remembers the last filter settings so if you don't capture the event on the first run, you just click on OK to overwrite the existing log to capture the cause of the error on subsequent attempts.

Also I have had many a computer tech tell me that there is no AV running on this computer. Ran Process Monitor and found that to not be the case. Windows Defender for instance will often be running, especially if there is no other AV running on the computer.

Hope this helps.

Cheers,

Marek.

#4 User is offline   cjakeman 

  • Vice President
  • PipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 2,857
  • Joined: 03-May 11
  • Gender:Male
  • Location:Peterborough, UK
  • Simulator:Open Rails
  • Country:

Posted 04 June 2020 - 10:26 AM

Hi Marek,

View Postsuperheatedsteam, on 03 June 2020 - 09:58 PM, said:

The 'go to' program to capture file contention is Sysinternals Process Monitor and it's free.


Thanks for all this detail. It will help me if I ever get the problem occurring on my own PC. If I can find a user confident enough to try this that will be a big step forward.


#5 User is offline   cjakeman 

  • Vice President
  • PipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 2,857
  • Joined: 03-May 11
  • Gender:Male
  • Location:Peterborough, UK
  • Simulator:Open Rails
  • Country:

Posted 04 June 2020 - 10:55 AM

View PostHamza97, on 03 June 2020 - 06:49 PM, said:

I would try getting log files of those if I can.

I have log files from 4 of the 5 users so far and I will continue to collect more. (My summary is in the first post above)


View PostHamza97, on 03 June 2020 - 06:49 PM, said:

The ONLY solution so far seems to be reinstalling Open Rails and keep AV OFF during playing.

To avoid Open Rails getting a bad reputation I am trying to find a better solution, especially since my contacts tell me re-installing does not always work.

Looking at the code, I can find nothing that could cause this directly. For example, Open Rails has no calls to the methods you might expect such as Path.GetTempFileName() and Path.GetRandomFileName(), nor is the text "tmp" present. I am wondering if the temp file is being created and accessed by a library used by Open Rails.

Ideas for a strategy to tackle this issue would be very welcome.


View PostHamza97, on 03 June 2020 - 06:49 PM, said:

This has happened to many users here in our MSTS community.

Also it would be helpful to know whether this happens only with the Stable version (as with the 5 examples I have seen) or also with Testing or MonoGame too? Can anyone help?

#6 User is offline   superheatedsteam 

  • Conductor
  • Group: Status: Contributing Member
  • Posts: 497
  • Joined: 28-June 08
  • Location:Perth, WA
  • Country:

Posted 04 June 2020 - 07:14 PM

Configuring Process Monitor looks worse than it is. To ease determining the cause, attached is a batch file and a configuration file that filters on “appdata\local\temp” path. If you extract both of these files in the same folder as Procmon.exe you can just run the batch file and it will create a log file called OR_TraceLog.PML. Minimise Process Monitor and run Open Rails. Once the error occurs, maximise Process Monitor and go to File>Exit. The PML can now be read by Process Monitor on another computer.

Test it yourself, make sure it works an pass it on to whomever is comfortable testing for you.

The re-installation of Open Rails is unlikely to be the resolution to this issue. The log clearly states that this is a file contention issue with a temporary file in the users profile. I strongly suspect the keep 'AV OFF' part is what will be resolving these issues.

I ran this batch file on my computer to test with OR v1.3.1.4328. These temp files are not created by the OpenRails.exe process.

On starting an Explore Route Activity the RunActivityLAA.exe process with the same version number as OpenRails.exe loads into memory and creates and deletes 30 temp files within 11 seconds.

After creating the temp file, the process wrote to that file once. The length of that file write varied from 151 to 933,925 bytes.

After the write operation to the temp file, my anti virus software accessed the file, made a query on the file, read the file then closed it.

The process then performs 6 CreateFileMapping operations on that temp file. As I understand it, this operation loads the contents of that file into memory. I'm not 100% sure that is the case as this is above my pay grade but the definition of it below may make more sense to you.

CreateFileMapping: corresponds to the NtCreateSection function; it creates or opens a named or unnamed "file mapping object", also called "section object" for a specified file, which represents a block of physical memory that two or more processes can share. The page protection type of the section object is indicated in the "detail" field.

The process then deletes the file.

Each temp file is created, actioned and deleted sequentially. The life span of these temp files is in the order of tenths to hundreds of seconds each.

The process never reads the files. It is always the same thread in that process that creates the temp files.

I tested the same scenario again and the same number of temp files with exactly the same size are created by the RunActivityLAA.exe process loading so so there is consistency here, on loading at least.

I tested with a default MSTS activity on Marias Pass and this time there was one temp file less created, but all the other files were exactly the same size in the same order.

Note that the life time of these temp files is very brief. It is not inconceivable that the that the Anti-Virus software may still be accessing the file when the instruction to delete the file is sent.

I drove the train in the activity and 13 minutes later, another temp file was created and deleted. While running the activity I used varying views, menu options, train control commands but that one temp file was created when there was no user input. Presumably the longer you run the activity the more temp files are created.

I hope this helps.

Cheers,

Marek.

Attached File(s)



#7 User is offline   Genma Saotome 

  • Owner Emeritus and Admin
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 15,308
  • Joined: 11-January 04
  • Gender:Male
  • Location:United States
  • Simulator:Open Rails
  • Country:

Posted 04 June 2020 - 10:20 PM

Procmon is an extremely useful file for understanding what's really going on under the hood. I've used it many times to figure out MSTS aborts. I wrote up a guide and pinned it, here.

#8 User is offline   cjakeman 

  • Vice President
  • PipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 2,857
  • Joined: 03-May 11
  • Gender:Male
  • Location:Peterborough, UK
  • Simulator:Open Rails
  • Country:

Posted 05 June 2020 - 10:51 AM

View PostGenma Saotome, on 04 June 2020 - 10:20 PM, said:

Procmon is an extremely useful file for understanding what's really going on under the hood. I've used it many times to figure out MSTS aborts. I wrote up a guide and pinned it, here.

Thanks, Dave. I've taken a copy.


View Postsuperheatedsteam, on 04 June 2020 - 07:14 PM, said:

I ran this batch file on my computer to test with OR v1.3.1.4328.

On starting an Explore Route Activity the RunActivityLAA.exe process with the same version number as OpenRails.exe loads into memory and creates and deletes 30 temp files within 11 seconds.

That's a terrific investigation, Marek - many thanks.

I'm hoping that I can find out what job these files are doing and that should help lead me to a solution.


Does anyone here bump into this problem and how did you overcome it?

#9 User is offline   cjakeman 

  • Vice President
  • PipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 2,857
  • Joined: 03-May 11
  • Gender:Male
  • Location:Peterborough, UK
  • Simulator:Open Rails
  • Country:

Posted 06 June 2020 - 01:51 AM

View PostHamza97, on 03 June 2020 - 06:49 PM, said:

This has happened to many users here in our MSTS community ..., I would try getting log files of those if I can ..., The ONLY solution so far seems to be reinstalling Open Rails and keep AV OFF during playing ....

I have founda Bug Report from March 2017 using Open Rails v1.2 with the same issue. At the time James commented on it and noted that it is "not part of Open Rails' own code - it is entirely inside the XNA graphics library we use."

That would explain why I cannot find any calls to creating temporary files or CreateFileMapping inside the Open Rails code.

As Marek has indicated, James also thought that it was an anti-virus issue and that solved the user's problem in 2017. Other users have denied this was the cause, but I do wonder whether they even know how to disable the Windows virus checker. Giving a free pass to the AppData\Local\Temp folder is dangerous though.


Some thoughts:

  • give detailed instructions to users on how to disable the Windows Anti-virus so they can try for themselves.
  • change the RunActivity code to catch the exception and perhaps recover gracefully
  • this may go away with v1.4 of Open Rails which will use MonoGame in place of XNA


#10 User is offline   cjakeman 

  • Vice President
  • PipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 2,857
  • Joined: 03-May 11
  • Gender:Male
  • Location:Peterborough, UK
  • Simulator:Open Rails
  • Country:

Posted 07 June 2020 - 02:32 AM

Just an update.

View Postcjakeman, on 06 June 2020 - 01:51 AM, said:

Other users have denied this was the cause, but I do wonder whether they even know how to disable the Windows virus checker. Giving a free pass to the AppData\Local\Temp folder is dangerous though.

  • give detailed instructions to users on how to disable the Windows Anti-virus so they can try for themselves.

Just heard back from the most recent user with this issue - success. It seems that some people don't want to admit that they don't know how to disable the Windows 10 virus checker but providing detailed instructions on how to disable it has done the trick.

I understand that the virus-checker cannot be permanently disabled (it re-enables itself silently after a few hours) but the problem may disappear with MonoGame in v1.4 of Open Rails.

Thanks to everyone here for your suggestions.

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users