Looky1173 / launchpad-bugs-migration2

0 stars 0 forks source link

[BUG n°1447222] ORTS.Processes.ThreadHangException at ORTS.Traveller.DistanceTo (X3008, ATSF Gallup Sub, Gallup Local - OR, path with two reverse loops (balloon track)) #376

Closed Looky1173 closed 9 years ago

Looky1173 commented 9 years ago

Imported from https://bugs.launchpad.net/bugs/1447222

Property Value
Reported by Markus Gelbmann (gelbmann-markus)
Date reported Wed, 22 Apr 2015 15:17:02 GMT
Tags crash

When the attached activity is run on Rober Wirths Gallup Subdivision (available on trainsim.com, search MSTS routes library section for "ATSF Gallup Sub Route" - six (6) files for download), the program freezes (frozen image on screen, sound keep running) upon trying to clear a path (signals) through the second reverse loop encountered along the player path. This problem is not encountered, when the path is shortened to start about 5 miles before diverging from the main route to the second loop.

It has been tried to insert reversal points in-between the two loops, to no avail. Also, it doesn´t make any difference if one switches to manual mode to do some shunting in-between passing the loops.

The problem was first encountered three quarters of a year ago, in X2186, but is still present today in X3008. Also, it likely has existed earlier than 2186 already.

Original maybe-it´s-a-bug report thread is located at http://www.elvastower.com/forums/index.php?/topic/24176-orts-simply-freezes-up-no-error-message-sound-keeps-running/

A log file from the most recent attempt to run the activity (autopiloted, time accelerated) can be found in this post at ET: http://www.elvastower.com/forums/index.php?/topic/24176-orts-simply-freezes-up-no-error-message-sound-keeps-running/page__view__findpost__p__178434

Looky1173 commented 9 years ago

Imported from https://bugs.launchpad.net/or/+bug/1447222/comments/1

Property Value
Posted by Markus Gelbmann (gelbmann-markus)
Date posted Wed, 22 Apr 2015 15:17:02 GMT
Looky1173 commented 9 years ago

Imported from https://bugs.launchpad.net/or/+bug/1447222/comments/2

Property Value
Posted by jeroenp (j-paasschens)
Date posted Sun, 26 Apr 2015 05:24:31 GMT

As is discussed in the elvastower discussion, the root cause of this is an infinite loop in Traveller.DistanceTo. DistanceTo 'runs' over the tracks following switches until a certain point is reached. But it is possible to have a loop (in this case because there are two balloon tracks and all switches are such that a free-running traveller/train would keep on looping from one balloon to the next). As a result, the DistanceTo never returns.

The solution is to to check for this kind of loops. I have a fix, but it might be a bit too large to count as a simple fix and since it is affecting a very core component, I would assume that it has to be done after 1.0

Best regards, Jeroen.

Looky1173 commented 9 years ago

Imported from https://bugs.launchpad.net/or/+bug/1447222/comments/3

Property Value
Posted by Carlo Santucci (carlosanit1)
Date posted Sun, 26 Apr 2015 08:17:56 GMT

Jeroen, I too had a thread hang on a nice urban tram line. With your patch the hang disappeared. So the fact that the patch removed an analogous problem in another route indicates that it is really OK! It is true that it is more than 5 lines and it is in a core component, but it changes simulation behaviour only in very particular cases. So I hope that James will give to you the OK to commit. Only two suggestions:

Looky1173 commented 9 years ago

Imported from https://bugs.launchpad.net/or/+bug/1447222/comments/4

Property Value
Posted by jeroenp (j-paasschens)
Date posted Sun, 26 Apr 2015 18:23:02 GMT

Dear all, my previous solution was intended to be a general solution to prevent all loops in DistanceTo. James suggested that maybe (software) users of DistanceTo should limit the search distance. For this particular problem this is also easy, I think. And, in this case the solution is probably more elegant as well because, first, a natural maximum distance is available, and second, it limits searching to a few meters or 10s of meters. Instead of 200km.

So I created another patch file that is to be used instead of the previous patchfile (both patch files work independently, but only one is needed for this problem). Now limited to 2 lines. I am curious to know whether this also solves the urban tram line issue.

Just out of curiosity, tennis racket, or reversing loop, is that not the same as balloon loop?

Best regards, Jeroen

Looky1173 commented 9 years ago

Imported from https://bugs.launchpad.net/or/+bug/1447222/comments/5

Property Value
Posted by James Ross (twpol)
Date posted Sun, 26 Apr 2015 19:15:13 GMT

Once tested, I am happy with the Activity.cs patch to provide a distance to DistanceTo. This is a very nice and simple fix and needed to be done anyway.

The changes to Traveller.cs I am understandably quite nervous about and would prefer it if we avoided making these changes right now. While it would be nice if Traveller was more robust, I don't know if it is a good idea to bake this kind of performance/reliability into the core - at least not for the moment.

Looky1173 commented 9 years ago

Imported from https://bugs.launchpad.net/or/+bug/1447222/comments/6

Property Value
Posted by Carlo Santucci (carlosanit1)
Date posted Sun, 26 Apr 2015 20:07:22 GMT

Sorry Jeroen, your activity patch does not solve my hangup. And by the way your activity patch does not apply to timetable mode. The traveller patch is for sure a more general solution, and I don't see many dangers in it, provided the test with a reversing loop is done. I don' know if you are asking me about the difference between reversing loop and balloon loop, or about the difference of behaviour of your patch those types of loop can cause. If the question is the first one, in the reversing loop the train exits the loop being orientated in the opposite direction, while in the balloon loop it exits the loop being orientated in the same direction.

Looky1173 commented 9 years ago

Imported from https://bugs.launchpad.net/or/+bug/1447222/comments/7

Property Value
Posted by James Ross (twpol)
Date posted Sun, 26 Apr 2015 20:24:45 GMT

Carlo, that would simply suggest a different DistanceTo is causing your hang, and therefor a different bug should be filed with your log.

I'm attaching the log for this bug here for comparison.

Looky1173 commented 9 years ago

Imported from https://bugs.launchpad.net/or/+bug/1447222/comments/8

Property Value
Posted by James Ross (twpol)
Date posted Sun, 26 Apr 2015 20:25:58 GMT
Looky1173 commented 9 years ago

Imported from https://bugs.launchpad.net/or/+bug/1447222/comments/9

Property Value
Posted by Carlo Santucci (carlosanit1)
Date posted Sun, 26 Apr 2015 20:51:50 GMT

I've added a new bug report for my crash here https://bugs.launchpad.net/or/+bug/1448772 .

Looky1173 commented 9 years ago

Imported from https://bugs.launchpad.net/or/+bug/1447222/comments/10

Property Value
Posted by jeroenp (j-paasschens)
Date posted Mon, 27 Apr 2015 19:28:15 GMT

Dear all, I realized that probably, in my first patch with the loop tester (so the Traveller.cs.patch), the return value in case of a loop should not be the maximum distance, but probably -1 (which is the indication of no distance found). Jeroen.

Looky1173 commented 9 years ago

Imported from https://bugs.launchpad.net/or/+bug/1447222/comments/11

Property Value
Posted by James Ross (twpol)
Date posted Mon, 27 Apr 2015 21:40:20 GMT
Looky1173 commented 9 years ago

Imported from https://bugs.launchpad.net/or/+bug/1447222/comments/12

Property Value
Posted by jeroenp (j-paasschens)
Date posted Thu, 30 Apr 2015 19:17:56 GMT

Dear all, I committed the activity.cs patch, 3049. Further improvements on activity.cs (see https://bugs.launchpad.net/or/+bug/1448772 ) might still be needed, but I think this one can be closed. Jeroen.