Compiled version won't run
Moderator: OpenTTD Developers
Compiled version won't run
First of all, my apologies for my newbishness and rather medicore English.
Having played OpenTTD for some time now I wanted to be able to compile my own version of the game. This to be able to make my own small changes, maybe work on a patch, etc. After solving a few minor issues I have now been able to compile openttd using microsoft visual express 2008. However, no matter what I tried, the compiled version won't run, it crashes right after starting up.
Could anyone give me some insight in this?
Having played OpenTTD for some time now I wanted to be able to compile my own version of the game. This to be able to make my own small changes, maybe work on a patch, etc. After solving a few minor issues I have now been able to compile openttd using microsoft visual express 2008. However, no matter what I tried, the compiled version won't run, it crashes right after starting up.
Could anyone give me some insight in this?
Create your own NewGRF? Check out this tutorial!
Re: Compiled version won't run
Yes. Your debugger.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
-
- Tycoon
- Posts: 1656
- Joined: 08 Jun 2007 08:00
Re: Compiled version won't run
That doesn't say anything about your problem...However, no matter what I tried, the compiled version won't run, it crashes right after starting up.
One issue I had was that source address had non-stanndard chars in it.. Like ö. then it said something about utf8 thing.. I compile in linux though so that information isn't adequate I'm afraid

madis
Re: Compiled version won't run
I have downloaded the latest scource code and haven't changed anything, so bad code shouldn't be an issue.DaleStan wrote:Yes. Your debugger.
I have attached the crash log, that might help...
Not sure what other files/information I should provide, please just ask for what you need.
- Attachments
-
- crash.txt
- openttd crash log
- (6.94 KiB) Downloaded 102 times
Create your own NewGRF? Check out this tutorial!
-
- Chairman
- Posts: 776
- Joined: 20 Jan 2007 12:08
- Location: Germany
Re: Compiled version won't run
As I'm running Linux I can only provide some general advice:
Did you put the required files from original TTD into the right place? I think sometimes missing files are not handled gracefully.
From the crash report I only see that it occurred in the openttd executable and not in a DLL. It would definitely help to compile with debugging information and run it under a debugger to find out, where exactly (i.e. in which function and line of code) it crashes.
If you got the source from SVN, providing the SVN revision could also help.
Did you put the required files from original TTD into the right place? I think sometimes missing files are not handled gracefully.
From the crash report I only see that it occurred in the openttd executable and not in a DLL. It would definitely help to compile with debugging information and run it under a debugger to find out, where exactly (i.e. in which function and line of code) it crashes.
If you got the source from SVN, providing the SVN revision could also help.
"The bigger the island of our knowledge, the longer the shore of our ignorance" - John A. Wheeler, Physicist, 1911-2008
Re: Compiled version won't run
But a bad compiler could be.Swallow wrote:I have downloaded the latest scource code and haven't changed anything, so bad code shouldn't be an issue.DaleStan wrote:Yes. Your debugger.
Hence, your debugger, to find out what's actually happening, as opposed to what should be happening.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Re: Compiled version won't run
Excuse me for my ignorance, these are my first steps from php/javascript into the world of serious programming. I have been juggling around with the debugger and the results are below. Now I hope someone is able to decipher them and find the cause of the problems.
EDIT: I'm using the scource r11995
Message
Unhandled exception at 0x00693f82 in openttd.exe: 0xC0000005: Access violation reading location 0x011a932c.
call stack
autos
The function which appears the cause the error is this: (spritecache.cpp)
EDIT: I'm using the scource r11995
Message
Unhandled exception at 0x00693f82 in openttd.exe: 0xC0000005: Access violation reading location 0x011a932c.
call stack
Code: Select all
> openttd.exe!DupSprite(unsigned int old_spr=4063, unsigned int new_spr=5863) Line 268 + 0x6 bytes C++
openttd.exe!ActivateOldShore() Line 5614 C++
openttd.exe!AfterLoadGRFs() Line 5677 C++
openttd.exe!LoadNewGRF(unsigned int load_index=6052, unsigned int file_index=4) Line 5726 C++
openttd.exe!LoadSpriteTables() Line 249 C++
openttd.exe!GfxLoadSprites() Line 260 C++
openttd.exe!GenerateWorld(int mode=1, unsigned int size_x=64, unsigned int size_y=64) Line 273 C++
openttd.exe!ttd_main(int argc=1, char * * argv=0x0012fe00) Line 571 C++
openttd.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000,
char * lpCmdLine=0x00151f15, int nCmdShow=1) Line 1003 C++
openttd.exe!__tmainCRTStartup() Line 263 + 0x2c bytes C
openttd.exe!WinMainCRTStartup() Line 182 C
kernel32.dll!7c816fd7()
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
openttd.exe!MakeNewEditorWorldDone() Line 735 + 0x10 bytes C++
52990840()
Code: Select all
new_spr 5863 unsigned int
- scnew 0x011c5e80 {ptr=0x00000000 id=0 file_pos=0 ...} SpriteCache *
ptr 0x00000000 void *
id 0 unsigned int
file_pos 0 unsigned int
file_slot 0 unsigned short
lru 0 short
scnew->file_slot 0 unsigned short
- scold 0x011a9320 {ptr=??? id=??? file_pos=??? ...} SpriteCache *
ptr CXX0030: Error: expression cannot be evaluated
id CXX0030: Error: expression cannot be evaluated
file_pos CXX0030: Error: expression cannot be evaluated
file_slot CXX0030: Error: expression cannot be evaluated
lru CXX0030: Error: expression cannot be evaluated
Code: Select all
void DupSprite(SpriteID old_spr, SpriteID new_spr)
{
SpriteCache *scold = GetSpriteCache(old_spr);
SpriteCache *scnew = AllocateSpriteCache(new_spr);
scnew->file_slot = scold->file_slot; <<--error appears here
scnew->file_pos = scold->file_pos;
scnew->ptr = NULL;
scnew->id = scold->id;
}
Create your own NewGRF? Check out this tutorial!
-
- Chairman
- Posts: 776
- Joined: 20 Jan 2007 12:08
- Location: Germany
Re: Compiled version won't run
Swallow wrote:EDIT: I'm using the scource r11995
So it seems that the scold pointer is pointing to invalid memory (although the address does not look that suspicious). Hmm, I compiled and used r11995 just yesterday under Linux, so I assume that there wasn't a general problem with this release.Swallow wrote:Code: Select all
- scold 0x011a9320 {ptr=??? id=??? file_pos=??? ...} SpriteCache * ptr CXX0030: Error: expression cannot be evaluated id CXX0030: Error: expression cannot be evaluated file_pos CXX0030: Error: expression cannot be evaluated file_slot CXX0030: Error: expression cannot be evaluated lru CXX0030: Error: expression cannot be evaluated
The function which appears the cause the error is this: (spritecache.cpp)Code: Select all
void DupSprite(SpriteID old_spr, SpriteID new_spr) { SpriteCache *scold = GetSpriteCache(old_spr); SpriteCache *scnew = AllocateSpriteCache(new_spr); scnew->file_slot = scold->file_slot; <<--error appears here scnew->file_pos = scold->file_pos; scnew->ptr = NULL; scnew->id = scold->id; }
Ohh, I think I found the problem: AllocateSpriteCache may reallocate the array, but scold still points to the position before the reallocation.
Swapping the first two lines of the function should fix it. Could you try that? If that fixes it I'll provide a patch and put it into flyspray, when I'm at home.
"The bigger the island of our knowledge, the longer the shore of our ignorance" - John A. Wheeler, Physicist, 1911-2008
Re: Compiled version won't run
The problem is failing version detection (happens only when you build nightly sources). This cause openttd?.grf loading to fail (won't happen once 0.6 branch is created).crash.txt wrote:Build: norev000 built on Jan 27 2008 13:42:52
For now you can fix it by using svn, or edit src/rev.cpp.in and replace @@REVISION@@ with 11995 (use the value corresponding to the downloaded source)
-
- Chairman
- Posts: 776
- Joined: 20 Jan 2007 12:08
- Location: Germany
Re: Compiled version won't run
So, if I understand correctly, this is why the bug is triggered for Swallow but not for me. But there still is a bug, or am I mistaken? AllocateSpriteCache can reallocate the memory making scold a dangling pointer.glx wrote:The problem is failing version detection (happens only when you build nightly sources). This cause openttd?.grf loading to fail (won't happen once 0.6 branch is created).crash.txt wrote:Build: norev000 built on Jan 27 2008 13:42:52
For now you can fix it by using svn, or edit src/rev.cpp.in and replace @@REVISION@@ with 11995 (use the value corresponding to the downloaded source)
Anyway, I just posted this to flyspray together with a patch: http://bugs.openttd.org/task/1717
"The bigger the island of our knowledge, the longer the shore of our ignorance" - John A. Wheeler, Physicist, 1911-2008
Re: Compiled version won't run
Using svn did the trick; many thanks 

Create your own NewGRF? Check out this tutorial!
Re: Compiled version won't run
Ignoring that class of bug is SOP, as far as I can tell.PhilSophus wrote:But there still is a bug, or am I mistaken? AllocateSpriteCache can reallocate the memory making scold a dangling pointer.
I don't know if that's the same bug or not, but I pointed out one of that class some time ago, and the answer was that if the memory was relocated, there were bigger problems than a mere dangling pointer.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Who is online
Users browsing this forum: No registered users and 1 guest