System.ArgumentException at ORTS.Viewer3D.RenderFrame.Sort (X2162 crash switching fast from car to car)

Bug #1305165 reported by Carlo Santucci
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Open Rails
Fix Released
Medium
Carlo Santucci

Bug Description

While being in passenger camera and switching fast from car to car I got a crash. Logfile attached.

Tags: crash graphics
Revision history for this message
Carlo Santucci (carlosanit1) wrote :
Revision history for this message
Carlo Santucci (carlosanit1) wrote :

The problem occurs at least since version x2146, but up to today never occurred, while today it always occurs.

Revision history for this message
Carlo Santucci (carlosanit1) wrote :

The problem has arisen passing from x2130 to x2131 (a modification where I have a noticeable responsibility...) and happens only with some wagons and does not seem to depend from speed in passing from one wagon to the other. Will have to investigate further...

Revision history for this message
Carlo Santucci (carlosanit1) wrote :

After further analysis I found out that the crash does not arise in x2164 loaded from SVN, while it arises in x2164 loaded from James'site... Now I'm clueless.

Revision history for this message
James Ross (twpol) wrote :

Chances are, we have a threading hazard somewhere. Therefore, even the machine you run OR on might be relevant to how likely this is to occur.

summary: - x2162 crash switching fast from car to car
+ System.ArgumentException at ORTS.Viewer3D.RenderFrame.Sort (X2162 crash
+ switching fast from car to car)
Revision history for this message
Carlo Santucci (carlosanit1) wrote :

This patch solves the problem. I think it is not a threading hazard.
In my opinion the arrangement that was inserted to discriminate between near objects not only leads to crash; it neither solves the problem of discriminating between near objects. For this reason I think that the problem of discriminating between near objects does not need to be addressed until a proof against this arises.

Revision history for this message
James Ross (twpol) wrote :

The problem with that patch is that it throws away and ignores the data specifically included to ensure closely-positioned items are drawn in the correct order. That isn't acceptable for obvious reasons.

Revision history for this message
Carlo Santucci (carlosanit1) wrote :

Ok, second trial.
This patch maintains the original comparison algorithm and only compacts it. The crash has disappeared.

Revision history for this message
James Ross (twpol) wrote :

Having just translated the error message for the first time, this crash makes no sense - with any version of the code. I can only assume floating point rounding is rearing its ugly head somehow.

I also can't get a crash here at all. :(

Revision history for this message
James Ross (twpol) wrote :

This is a version of RunActivity/RunActivityLAA with the changes in the patch but also Math.Sign() replaces by a typecast to (int). Please let me know how it works out before I commit it.

Changed in or:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → James Ross (twpol)
Revision history for this message
Carlo Santucci (carlosanit1) wrote :

You can e.g. download:
- this high speed trainset: http://www.trainsimhobby.net/infusions/pro_download_panel/download.php?did=985 :one of its passenger views crashes to me
- or download this narrow gauge trainset: http://rhbformsts.spoorpunt.nl/EWIV.php?m=2 where the passenger view of trainset RhB_BD2475.wag crashes to me.

Revision history for this message
cjakeman (cjakeman) wrote :

May be a long shot, but this stack trace looks very similar to the inner exception part of the one reported in Bug 1300942:

Error: System.InvalidOperationException: Failed to compare two elements in the array. ---> System.ArithmeticException: Function does not accept floating point Not-a-Number values.
   at System.Math.Sign(Single value)
   at ORTS.Viewer3D.RenderItem.Comparer.Compare(RenderItem x, RenderItem y)
   at System.Collections.Generic.ArraySortHelper`1.QuickSort(T[] keys, Int32 left, Int32 right, IComparer`1 comparer)
   at System.Collections.Generic.ArraySortHelper`1.Sort(T[] keys, Int32 index, Int32 length, IComparer`1 comparer)
   --- End of inner exception stack trace ---
   at System.Collections.Generic.ArraySortHelper`1.Sort(T[] keys, Int32 index, Int32 length, IComparer`1 comparer)
   at System.Array.Sort[T](T[] array, Int32 index, Int32 length, IComparer`1 comparer)
   at System.Collections.Generic.List`1.Sort(Int32 index, Int32 count, IComparer`1 comparer)
   at System.Collections.Generic.List`1.Sort(IComparer`1 comparer)
   at ORTS.Viewer3D.RenderFrame.Sort()
   at ORTS.Processes.UpdaterProcess.Update()
   at ORTS.Processes.UpdaterProcess.DoUpdate()
   at ORTS.Processes.UpdaterProcess.UpdaterThread()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
for which we may have a fix,

Chris

Revision history for this message
James Ross (twpol) wrote :

Chris,

I don't believe they are related, although the crash is very close-by. In this bug we're returning non-zero from RenderItem+Comparer.Compare when x == y which seems to be fixed by rearranging the order of operations. In bug 1300942 we're coming in to that function with NaN values which blow up differently.

Changed in or:
status: In Progress → Fix Committed
milestone: none → 1.0
assignee: James Ross (twpol) → Carlo Santucci (carlosanit1)
Revision history for this message
James Ross (twpol) wrote :

This bug should be fixed in X2178. Thanks Carlo!

James Ross (twpol)
Changed in or:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.