The TORCS Racing Board
Username: Password: Remember Me?
Lost Password Register
Author: timfoden | Created: 2017-08-02 10:04:52
Subject: 2017 Race 4 -- Hidden Valley -- TORCS Crash
Hi Guys,

Everything built OK and seem to run fine, but TORCS crashed on lap 49 of my race. It happened late last night, and I haven't yet had time to investigate.

Anyone else had any problems?

Cheers, Tim.
Last Edited: 2017-08-02 15:32:15 by timfoden
    Author: firechief | Created: 2017-08-02 10:39:09
    Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
    Haven't run it yet - will let you know.
    Last Edited: 2017-08-02 10:39:09 by firechief
    Author: dummy | Created: 2017-08-02 10:42:21
    Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
    Didn't crash in my race. But the possibility of crashing is always there and that's why I always run with debug mode enabled.
    Last Edited: 2017-08-02 10:42:21 by dummy
      Author: timfoden | Created: 2017-08-03 07:27:04
      Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
      Just tried running with a debug build and VS2008 finds a runtime error in Klin:

      Run-Time Check Failure #3 - The variable 'sPEED' is being used without being initialized.

      path.cpp, lines 2369 and 2370:

      double leftAng = MaxSteer(nlefto, CarToLetPass, car, steer, accel, MAXSTEER_LEFT, MNG_OVERLAPPERS_IN_LEFTRIGHT, Index, sPEED);
      double rightAng = MaxSteer(nrighto, CarToLetPass, car, steer, accel, MAXSTEER_RIGHT, MNG_OVERLAPPERS_IN_LEFTRIGHT, Index, sPEED);
      Last Edited: 2017-08-03 07:27:04 by timfoden
        Author: phi | Created: 2017-08-03 11:40:05
        Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
        I'll take care of this, thank you.
        Last Edited: 2017-08-03 11:40:05 by phi
          Author: timfoden | Created: 2017-08-03 18:57:23
          Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
          No problem :)

          I made a temporary fix so I could run the race in debug mode by setting sPEED to 0 at line 2289 where it is declared.

          Lap 9 of the race has show up another variable with the same problem but this time called invXspeed in the MaxSteer function.

          Its in path.cpp on line 1697:

          const double maxang = invXspeed / (maxangFactor * MAXinvXspeed);

          ... this variable doesn't appear to be assigned to at all in this function.

          And although it hasn't yet been picked up in by the debugger I think that the sidedist variable in this function is also uninitialised before it's use in the else-if on line 1680.

          Cheers, Tim.
          Last Edited: 2017-08-03 19:03:58 by timfoden
            Author: phi | Created: 2017-08-03 20:04:54
            Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
            They are defined into 'else if' condition, but I set it to '0', now, before that. I have to be more attentive to this subject.

            This way they get a bit dark and hard to see, but (especially for invXspeed) they only require calculation when the condition arises; in addition, this condition is poorly written, and invXspeed may never have a value that is expected to have. Anyway, only the sidedist will appear in the next version - most likely...
            Last Edited: 2017-08-03 20:04:54 by phi
    Author: phi | Created: 2017-08-02 11:40:29
    Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
    Hi, Tim. Everything ok, here.
    Last Edited: 2017-08-02 11:40:29 by phi
    Author: timfoden | Created: 2017-08-02 15:32:27
    Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
    Thanks guys. I'll try to post a release mode stack trace when I get home tonight, but I'm going out so probably won't be able to do much more than that this evening.
    Last Edited: 2017-08-02 15:32:27 by timfoden
    Author: timfoden | Created: 2017-08-02 18:43:41
    Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
    OK, the crash "problem details" message said:

    Problem signature:
    Problem Event Name: BEX
    Application Name: wtorcs.exe
    Application Version: 0.0.0.0
    Application Timestamp: 5980dccf
    Fault Module Name: fa1_2017.dll
    Fault Module Version: 0.0.0.0
    Fault Module Timestamp: 5980122a
    Exception Offset: 000392a3
    Exception Code: c0000417
    Exception Data: 00000000
    OS Version: 6.1.7601.2.1.0.256.1
    Locale ID: 2057
    Additional Information 1: 0940
    Additional Information 2: 09405949343ce1beae3e0a42f9a2c67d
    Additional Information 3: 198c
    Additional Information 4: 198cbc76f6945140e73a6a1bcaa74ea7

    ... which points to fa1. And as it happens I was watching all the cars pretty carefully for anything of interest in this re-run of the race and fa1 had literally just stopped in the pit (and I think this is pit 7 -- it is if the index starts from 0). Strange though as the fa1 cars had both successfully pitted a number of times before, although at this time the other car was out of the race.

    Unfortunately choosing Debug from the crash report failed to stop in the debugger so no stack trace available.

    Cheers, Tim.
    Last Edited: 2017-08-02 18:43:41 by timfoden
      Author: dummy | Created: 2017-08-02 20:16:35
      Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
      Thanks Tim,

      This is a bug which may only occur on this track then. If you can't submit a result it's not a big deal as long as the rest of us can.
      Last Edited: 2017-08-02 20:16:35 by dummy
        Author: wdbee | Created: 2017-08-02 20:23:19
        Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
        AFAIK it is the old bug we already saw at other tracks.

        BUT: Have a look to the code, Fabian added try ... catch statements for all calls to the DLL, but the dump lists an exception as reason.

        For me it looks like a compiler issue. What compiler do you use Tim?


        Last Edited: 2017-08-02 20:23:19 by wdbee
          Author: timfoden | Created: 2017-08-02 20:32:14
          Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
          I use visual studio 2008 (short reply from phone)
          Last Edited: 2017-08-02 20:32:14 by timfoden
            Author: wdbee | Created: 2017-08-02 20:33:50
            Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
            So do I (Express Version), and I saw this bug here earlier as well, while Fabian using VC 2010 cannot reproduce it :(
            Last Edited: 2017-08-02 20:33:50 by wdbee
              Author: firechief | Created: 2017-08-03 14:41:33
              Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
              Silly question - why don't you guys upgrade to a later version?

              I'm running 2013 Community with no issues. I spent half an hour trying to compile it with 2015 Community a few months back but ran into some issues I didn't have time or patience to solve, and haven't tried it with 2017 yet. But sticking with a compiler that's nearly 10 years old has got to be a recipe for problems.
              Last Edited: 2017-08-03 14:42:01 by firechief
                Author: wdbee | Created: 2017-08-04 14:18:53
                Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
                Well the libraries for TORCS are made with VC2008 and VC6 and I have some real world pojects using special hardware needing drivers that are limited to VC2008 ( e.g. one using Win CE with an ARM processor needing a dedicated VC2008 - Win CE SDK).

                VC2010 was installed but after a Windows update it was deregistered for unknown reason and there is no way to register it again (Link not working anylonger).

                Last Edited: 2017-08-04 14:18:53 by wdbee
            Author: dummy | Created: 2017-08-02 22:19:02
            Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
            I ran a race with fa1 on pit 7. They made 4 pit stops each and nothing happened.
            Last Edited: 2017-08-02 22:19:02 by dummy
          Author: phi | Created: 2017-08-02 22:58:48
          Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
          I did a quick read on 'BEX' (Buffer Overflow Exception) in the Microsoft forums. In short, most, if not all, report 'DEP' (Data Execution Prevention) on Windows properties -- some 'BEX' are solved by extracting the offending program from 'DEP', others do not... The 'DEP' system closes the program in case it considers that there is any threat to the security of the machine's memory; it seems that 'DEP' goes beyond any exception handler.
          Last Edited: 2017-08-02 22:58:48 by phi
            Author: wdbee | Created: 2017-08-03 07:38:59
            Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
            Sounds like DEP is handled by the OS not by the compiled program.
            I saw the BEX at Win10, Tim and Fabian, what are you using?

            Edit: Looking for the error code I saw the post below. The code shows such an error using the std::vector class with VC2008 in release mode with optimization, and AFAIK this is what Fabian uses here, means it would be a compiler issue.

            https://social.msdn.microsoft.com/Forums/vstudio/en-US/02cd4552-b23c-4bce-934d-fe19e71bbb77/vc2008-x64-optimization-bug?forum=vclanguage
            Last Edited: 2017-08-03 07:54:17 by wdbee
              Author: timfoden | Created: 2017-08-03 10:45:06
              Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
              I'm using Windows 7.

              I notice that the article in the link you posted was referring the the 64bit compiler. I believe that the project for building TORCS is set to use the 32bit one.
              Last Edited: 2017-08-03 10:45:06 by timfoden
                Author: phi | Created: 2017-08-03 11:37:51
                Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
                I have the same, with DEP working on "just essential programs and services to windows", and nothing has happened. However, both fa1 ended.

                I ran a Hidden Valley with only one fa1, and he went to the pits without something happening. However, in your case, both started the race, and to reproduce this situation it would be necessary to change the fa1 code and I do not know it well for that.

                Besides this we do not know exactly which situation that triggers the error.
                Last Edited: 2017-08-03 11:37:51 by phi
                Author: wdbee | Created: 2017-08-03 12:27:12
                Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
                True, but I do not know was it tested with x64 only or did it happen with x64 only.

                From the earlier crash I know, that std::vector was somehow the reason. And Fabian does not get the issue using VC2010, just as mentioned in the link.


                Last Edited: 2017-08-03 12:27:12 by wdbee
                  Author: phi | Created: 2017-08-03 14:13:27
                  Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
                  Well, I can run a Hidden Valley in VS2008 build. Maybe at the end of the day I can have the results.
                  Last Edited: 2017-08-03 14:13:27 by phi
                    Author: phi | Created: 2017-08-03 19:27:58
                    Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
                    Everything went ok; both FA1 finished the race.
                    Last Edited: 2017-08-03 19:27:58 by phi
      Author: dummy | Created: 2017-08-02 20:36:16
      Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
      I just noticed why it can't happen in my race. fa1_2017 doesn't qualify for pit 7 ;)
      Last Edited: 2017-08-02 20:36:16 by dummy
        Author: fa1 | Created: 2017-08-03 20:18:59
        Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
        Agreed, we would have loved to qualify for pit 7! 8-)
        Last Edited: 2017-08-03 20:18:59 by fa1
        Author: phi | Created: 2017-08-03 20:29:19
        Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
        In my race, FA1 stayed in pit 7 (according to Tim's calculations, which starts counting from the '0').
        Last Edited: 2017-08-03 20:29:19 by phi
      Author: timfoden | Created: 2017-08-03 22:46:42
      Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
      OK, I built the debug version and ran that in a race, and quite eventful it has been so far. And lo and behold, fa1 had a problem when pitting for probably it's last pitstop on its lap 53 (lap 55 for the main runners.)

      It threw an exception from line 770 in pit.cpp:

      Stint& curr_stint = pitstrategy.stints[stint];

      The value of stint is 4, and the length of pitstrategy.stints is 4... :/

      [curr_fuel = 3.9016890525817871
      fuel_per_lap = 4.7075503685257649
      laps_per_fuel = 19]

      I'll leave it there stopped in the debugger, in case there are some more questions about the value of other variables in the program when this occurred. Off to bed now.

      Cheers, Tim.

      EDIT: looks like it exits the for loop on line 749 without finding a stint... some more variable values...
      cur_lap = 53
      tot_laps = 52
      pitstrategy.stints[x].laps = {14, 12, 13, 12}

      EDIT 2: No more questions about this yet, so I think I'll try edit the 2nd if (line 768) that says (stint >= 0) to say (stint >= 0 && stint < (int)pitstrategy.stints.size()) and then re-run the release build version of the race to see if that solves the original issue I had.
      Last Edited: 2017-08-04 15:12:50 by timfoden
        Author: timfoden | Created: 2017-08-04 18:27:31
        Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
        OK, that worked... I was able to run the whole race.

        Cheers, Tim.
        Last Edited: 2017-08-04 18:27:31 by timfoden
        Author: phi | Created: 2017-08-05 00:07:03
        Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
        Nice work, Tim.

        According to the documentation, only std::vector::at triggers an exception. Is the reason why FA1 does not catch the exception. So, the indices must be strongly checked.
        Last Edited: 2017-08-05 00:07:03 by phi
        Author: dummy | Created: 2017-08-05 13:52:57
        Subject: Re: 2017 Race 4 -- Hidden Valley -- TORCS Crash
        Yes, nice work indeed.

        That's the reason I always run in debug mode. It potentially saves me a lot of time.
        Last Edited: 2017-08-05 13:52:57 by dummy