The TORCS Racing Board
Username: Password: Remember Me?
Lost Password Register
Author: timfoden | Created: 2017-07-11 00:55:42
Subject: Klin needs to strdup the robot's name and description.
Hi Guys,

Klin crashes for me when setting up a race as it needs the changes to strdup() the robot info strings.

Change lines 147 & 148 in klin.cpp from:

modInfo[i].name = name;
modInfo[i].desc = desc;
to

modInfo[i].name = strdup(name);
modInfo[i].desc = strdup(desc);

EDIT: my race locks up, and each time I stop the program (built in release mode at this point) in the debugger the stack trace is the same...

> klin.dll!065f61fd()
[Frames below may be incorrect and/or missing, no symbols loaded for klin.dll]
klin.dll!065f128b()
klin.dll!065f139a()
client.dll!10012c80()
client.dll!10012def()
ntdll.dll!77ba011a()

An infinite loop perhaps? haven't got any further debugging yet... time for bed now.

Cheers, Tim.
Last Edited: 2017-07-11 01:37:02 by timfoden
    Author: phi | Created: 2017-07-11 02:28:33
    Subject: Re: Klin needs to strdup the robot's name and description.
    Hi

    I will fix strdup().

    As for the second problem, I have no idea what it might be. The program always worked well with me.

    Regards
    Last Edited: 2017-07-11 02:28:33 by phi
      Author: firechief | Created: 2017-07-11 03:08:30
      Subject: Re: Klin needs to strdup the robot's name and description.
      Its hanging TORCS for me as well. I compiled it in debug mode (Visual Studio 2013) and when I break execution its at line 2471 of path.cpp.

      Unfortunately I can't take it any further as the contents of the variables are all corrupted :\
      Last Edited: 2017-07-11 03:08:30 by firechief
        Author: phi | Created: 2017-07-11 06:45:11
        Subject: Re: Klin needs to strdup the robot's name and description.
        Hi

        I've never compiled on debugging. Maybe the problem is there in this mode (?), since I also use VS 2013 and it never happened to me... could it be? Anyway, if the problem is in this macro, it seems to me that it can only come from 'distance = 0' (L2465); so, please, replace line 2365:

        if(distance < 0) distance = 0;

        by the following line:

        if(distance <= 0) distance = 0.01;

        Regards

        [PS] lines in path.cpp
        Last Edited: 2017-07-11 06:47:25 by phi
          Author: timfoden | Created: 2017-07-11 08:54:06
          Subject: Re: Klin needs to strdup the robot's name and description.
          > I've never compiled on debugging. Maybe the problem is there in this mode (?)

          No, I saw it in release mode, as I mentioned, and you might also deduce from the minimal stack trace info. I just attached a debugger to the running (but locked up) executable to see what I could find out, as sometimes bugs like this only show up in the release build, and I didn't have time before going to bed to try a debug build. I'm using VS2008 by the way.

          > so, please, replace line 2365:

          This worked for me when I tried it this morning. I haven't run the whole race yet though, perhaps only about a third of it.

          Cheers, Tim.
          Last Edited: 2017-07-11 08:54:06 by timfoden
            Author: phi | Created: 2017-07-11 09:37:24
            Subject: Re: Klin needs to strdup the robot's name and description.
            >>> Yes, you're right. Thanks.

            >>> Good. In the next race I will revisit the code to see if there are more of these possible NaN.
            Last Edited: 2017-07-11 09:37:24 by phi
            Author: firechief | Created: 2017-07-11 15:58:41
            Subject: Re: Klin needs to strdup the robot's name and description.
            I'd also suggest making the same change on line 2220.

            Unfortunately I've already submitted my result without Klin, as I've got a very busy week ahead of me and only had time to run the race yesterday (I can obviously run it anytime, but in order to produce my reviews I have to watch it closely and take lots of screenshots, I can't just let it run in the background).

            If I get a chance I'll definitely run it again and give you as much helpful feedback as I can - writing a robot from scratch is far from easy & I admire you for taking it on!
            Last Edited: 2017-07-11 15:58:41 by firechief
              Author: phi | Created: 2017-07-11 21:22:10
              Subject: Re: Klin needs to strdup the robot's name and description.
              Line 2220 corrected. Now is: if(distance <= 0) distance = .01;


              No problem you have raced without Klin. Your reviews are nice, a good feedback themselves, and I can imagine that they give you a lot of dedicated work and are a time consuming task.

              Thanks alot for everything, Andrew. TORCS and TRB is a bit intimidating (there is a great deal of knowledge and techniques and methods and experience), and these words and attitudes are very helpful in all the development that can be done here.
              Last Edited: 2017-07-11 21:22:10 by phi
          Author: wdbee | Created: 2017-07-11 17:04:52
          Subject: Re: Klin needs to strdup the robot's name and description.
          Wellcome!

          here it worked after stdup and = 0.01 fix AND replacing all "Klin" by "klin", I do not know which "Klin" did make TORCS not load the driver. (Windows, VC2008 Express)

          Wolf-Dieter
          Last Edited: 2017-07-11 17:04:52 by wdbee
            Author: phi | Created: 2017-07-11 21:23:30
            Subject: Re: Klin needs to strdup the robot's name and description.
            Thanks Wolf-Dieter

            I compiled and ran a Klin 'Windows 32 VS2008 Pro' without any problems. I have no idea what it might be...

            Regards
            Last Edited: 2017-07-11 21:23:30 by phi
              Author: firechief | Created: 2017-07-12 04:57:32
              Subject: Re: Klin needs to strdup the robot's name and description.
              Actually I had the same problem as Wolf-Dieter, sorry I forgot to mention it. The visual studio project creates a library called "klin.dll", the xml is also klin, but the directory is Klin. It built ok, but the game wasn't listing the robot until I renamed all the upper case to klin.
              Last Edited: 2017-07-12 04:57:32 by firechief
                Author: phi | Created: 2017-07-12 05:47:01
                Subject: Re: Klin needs to strdup the robot's name and description.
                In my VS2008 and VS2013 builds all names are in lower case. The problem was solved if I changed the names of the project files to lowercase?
                Last Edited: 2017-07-12 05:47:01 by phi
                  Author: firechief | Created: 2017-07-12 06:16:26
                  Subject: Re: Klin needs to strdup the robot's name and description.
                  Not the project files - the directory name. Make that lower case and you should be fine.
                  Last Edited: 2017-07-12 06:16:26 by firechief
                    Author: phi | Created: 2017-07-12 07:07:54
                    Subject: Re: Klin needs to strdup the robot's name and description.
                    Ok. Output Directory '$(SolutionDir)runtime\drivers\$(ProjectName)' changed to '$(SolutionDir)runtime\drivers\klin'. It's curious that $(ProjectName) macro works fine in Linker but not in OutDir.
                    Last Edited: 2017-07-12 07:07:54 by phi
                      Author: wdbee | Created: 2017-07-12 07:28:33
                      Subject: Re: Klin needs to strdup the robot's name and description.
                      The logic might be C relevant parts are "klin" and filesystem relevant parts are ProjectName ("Klin") (For Windows it is same as klin, but for Linux and TORCS it is different). The natural way to solve the issues would be to use "klin" as project name.

                      Last Edited: 2017-07-12 07:28:50 by wdbee
                        Author: phi | Created: 2017-07-12 12:11:30
                        Subject: Re: Klin needs to strdup the robot's name and description.
                        I think I understand, thanks.
                        Last Edited: 2017-07-12 12:11:30 by phi