MegaGlest Forum

MegaGlest => Bug reports => Topic started by: SlowMO on 28 December 2013, 07:43:26

Title: Invalid unitToAttackId in Island Survival Scenario
Post by: SlowMO on 28 December 2013, 07:43:26
While playing Island Survival I got an "Invalid unitToAttackId..." error and the scenario game quit.
Here is the terminal output:
Code: [Select]
gamedir [/home/user/megaglest]
Looking for LDCONFIG []...
LDCONFIG environment variable is not set...
Found LDCONFIG using which [/sbin/ldconfig]...
default library [/home/user/megaglest/lib/libopenal.so.1] was found in [/usr/lib/x86_64-linux-gnu/libopenal.so.1]
default library [/home/user/megaglest/lib/libdirectfb-1.2.so.0] is missing, attempting to find and link to a newer version if available...
new library link [/usr/lib/libdirectfb-1.2.so.9] pointed to from [/home/user/megaglest/lib/libdirectfb-1.2.so.0]
default library [/home/user/megaglest/lib/libfusion-1.2.so.0] is missing, attempting to find and link to a newer version if available...
new library link [/usr/lib/libfusion-1.2.so.9] pointed to from [/home/user/megaglest/lib/libfusion-1.2.so.0]
default library [/home/user/megaglest/lib/libdirect-1.2.so.0] is missing, attempting to find and link to a newer version if available...
new library link [/usr/lib/libdirect-1.2.so.9] pointed to from [/home/user/megaglest/lib/libdirect-1.2.so.0]
default library [/home/user/megaglest/lib/libjpeg.so.62] was found in [/usr/lib/i386-linux-gnu/libjpeg.so.62]
default library [/home/user/megaglest/lib/libpng15.so.15] is missing, attempting to find and link to a newer version if available...
new library link [/lib/x86_64-linux-gnu/libpng12.so.0] pointed to from [/home/user/megaglest/lib/libpng15.so.15]
default library [/home/user/megaglest/lib/libcurl.so.4] was found in [/usr/lib/x86_64-linux-gnu/libcurl.so.4]
default library [/home/user/megaglest/lib/libxerces-c-3.1.so] is missing, attempting to find and link to a newer version if available...
default library [/home/user/megaglest/lib/libicudata.so.40] is missing, attempting to find and link to a newer version if available...
new library link [/usr/lib/libicudata.so.48] pointed to from [/home/user/megaglest/lib/libicudata.so.40]
default library [/home/user/megaglest/lib/libicuuc.so.40] is missing, attempting to find and link to a newer version if available...
new library link [/usr/lib/libicuuc.so.48] pointed to from [/home/user/megaglest/lib/libicuuc.so.40]
default library [/home/user/megaglest/lib/libGLEW.so.1.5] was found in [/usr/lib/libGLEW.so.1.5]
default library [/home/user/megaglest/lib/libGLEW.so.1.5] was found in [/usr/lib/libGLEW.so.1.5]
default library [/home/user/megaglest/lib/libogg.so.0] was found in [/usr/lib/x86_64-linux-gnu/libogg.so.0]
default library [/home/user/megaglest/lib/libvorbis.so.0] was found in [/usr/lib/x86_64-linux-gnu/libvorbis.so.0]
default library [/home/user/megaglest/lib/libvorbisfile.so.3] was found in [/usr/lib/x86_64-linux-gnu/libvorbisfile.so.3]
default library [/home/user/megaglest/lib/libfontconfig.so.1] was found in [/usr/lib/x86_64-linux-gnu/libfontconfig.so.1]
default library [/home/user/megaglest/lib/libfreetype.so.6] was found in [/usr/lib/x86_64-linux-gnu/libfreetype.so.6]
default library [/home/user/megaglest/lib/libgnutls.so.26] was found in [/usr/lib/x86_64-linux-gnu/libgnutls.so.26]
default library [/home/user/megaglest/lib/libldap_r-2.4.so.2] was found in [/usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2]
default library [/home/user/megaglest/lib/libresolv.so.2] was found in [/lib/x86_64-linux-gnu/libresolv.so.2]
default library [/home/user/megaglest/lib/liblua5.1.so.0] was found in [/usr/lib/x86_64-linux-gnu/liblua5.1.so.0]
default library [/home/user/megaglest/lib/libftgl.so.2] is missing, attempting to find and link to a newer version if available...
default library [/home/user/megaglest/lib/libircclient.so.1] is missing, attempting to find and link to a newer version if available...
default library [/home/user/megaglest/lib/libdl.so.2] was found in [/lib/x86_64-linux-gnu/libdl.so.2]
default library [/home/user/megaglest/lib/libvlccore.so.5] is missing, attempting to find and link to a newer version if available...
default library [/home/user/megaglest/lib/libvlc.so.5] is missing, attempting to find and link to a newer version if available...
default library [/home/user/megaglest/lib/libgcrypt.so.11] was found in [/lib/x86_64-linux-gnu/libgcrypt.so.11]
megaglest v3.9.0
Compiled using: GNUC: 40403 [64bit] on: Nov 17 2013 14:59:59 platform: Linux-X64 endianness: little
SVN: [Rev: 4846] - using STREFLOP [SSE] - [no-denormals]
Game unique identifier is: 34200aae-6f5d-11e3-bb7d-73a0998350f0
Triggering daynight event isDay: 0 [18.000450]
daynight toggle isnight = 1 monsters = start
daynight toggle isnight = 1 monsters2 = start
*ERROR* In [game.cpp::update Line: 2735] Error [Invalid unitToAttackId index in giveAttackCommand: 700114 unitToAttackId = 46
Stack Trace:
./megaglest:Shared::Platform::megaglest_runtime_error::megaglest_runtime_error(std::string const&, bool)address [0xbc64be] line: 299
./megaglest:Glest::Game::World::giveAttackCommand(int, int)address [0xab2cb6] line: 1505
./megaglest:Glest::Game::ScriptManager::giveAttackCommand(lua_State*)address [0x6b1222] line: 2155
./megaglest() [0xd9a129]address [0xd9a129]
./megaglest() [0xda3839]address [0xda3839]
./megaglest() [0xd9a5ed]address [0xd9a5ed]
./megaglest() [0xd99cc7]address [0xd99cc7]
./megaglest() [0xd99d42]address [0xd99d42]
./megaglest:lua_pcall()address [0xd9740f] line: 0
./megaglest:Shared::Lua::LuaScript::endCall()address [0xb6c2e1] line: 595
./megaglest:Glest::Game::ScriptManager::onDayNightTriggerEvent()address [0x6ad066] line: 1893
./megaglest:Glest::Game::World::update()address [0xac038e] line: 834
./megaglest:Glest::Game::Game::update()address [0x67cff2] line: 2153
./megaglest:Glest::Game::Program::loopWorker()address [0x7aa878] line: 476
./megaglest:Glest::Game::glestMain(int, char**)address [0x79e172] line: 5412
./megaglest:Glest::Game::glestMainSEHWrapper(int, char**)address [0x7a22f1] line: 5660
./megaglest:Glest::Game::glestMainWrapper(int, char**)address [0x7a24d8] line: 5732
/lib/x86_64-linux-gnu/libc.so.6:__libc_start_main()address [0x7f062787676d] line: 0
./megaglest() [0x5ee9b9]address [0x5ee9b9]
]

This is on version 3.9.0 (Built Nov 7, 2013 Rev: 4846) running on Ubuntu 12.4 on a Lenovo W510, i7 processor, 16GB RAM.  Downloaded from megaglest.org.
I saved the game less than a minute before this error occurs.  I can repeat this error every time by loading the saved game and just waiting, or doing just about anything.  It fails every time.
I can send the saved game, if needed.
Title: Re: Invalid unitToAttackId in Island Survival Scenario
Post by: Omega on 28 December 2013, 22:43:45
I'm not sure if this is a problem with MegaGlest so much as the Island Survival scenario.

It's unfortunate that the error messages don't specify the line of the Lua script that made this invalid call. I imagine this is a case of a giveAttackCommand call that is using the ID of a dead unit as either the target or source.

If one of the devs can verify that this is indeed due to the scenario, I'll merge this into the island survival thread.

Perhaps these kinds of errors should state the location of the error in the script, however? The error message posted doesn't seem very useful to scenario developers.

@SlowMO, could you upload your save file? I imagine that Tiger will find that useful in tracking down where in his scenario this occurs.
Title: Re: Invalid unitToAttackId in Island Survival Scenario
Post by: SlowMO on 29 December 2013, 04:35:09
I am not seeing where I can upload the file.
Title: Re: Invalid unitToAttackId in Island Survival Scenario
Post by: tomreyn on 29 December 2013, 19:16:42
The forum doesn't provide a way to upload files, please use any file hosting site which allows for free and direct downloads.
Title: Re: Invalid unitToAttackId in Island Survival Scenario
Post by: titi on 30 December 2013, 00:08:33
I am quite sure too that this is a bug in the scenario code. ( https://forum.megaglest.org/index.php?topic=9276.0)
Title: Re: Invalid unitToAttackId in Island Survival Scenario
Post by: tiger on 30 December 2013, 00:48:37
This is an error in the scenario.
It is caused by the survival island scenario.
The Cause is that one of your main buildings (such as house or defence tower) has died. Unit spawn and attack those units which causes the game to crash.
This may be fixed in the next release of the scenario. But for now just don’t let your "main" buildings die.
Title: Re: Invalid unitToAttackId in Island Survival Scenario
Post by: tomreyn on 30 December 2013, 01:18:56
While the trigger is a bug in the scenario, ideally buggy scenarios should not have the potential to crash the game entirely. Instead, what should happen is that a message window pops up saying that the scenario encountered a problem and had to be ended, returning the user to the main menu or, if it cannot be guaranteed that the game will continue to be stable after this point, should state that the game will have to quit as a result and do so as soon as the user confirms the message.
Title: Re: Invalid unitToAttackId in Island Survival Scenario
Post by: tiger on 30 December 2013, 02:00:38
Yes I agree, that should not be a reason for the game to end.
Title: Re: Invalid unitToAttackId in Island Survival Scenario
Post by: SlowMO on 30 December 2013, 06:53:45
It is the scenario that died, and the game does return to the main menu, so the exception handling appears to be working fine.  The error message just needs to be "cleaner" that it is a problem with the scenario.  It's nice to know not to let my main buildings die.  When I moved to the 1.2 version of the scenario, it is less likely to happen now that the bees don't spawn till later and are not quite so aggressive.
BTW, this is a great scenario, thanks Tiger.
Title: Re: Invalid unitToAttackId in Island Survival Scenario
Post by: softcoder on 30 December 2013, 10:02:10
I committed an update in git HEAD which will display the error in a messagebox and not exit the game (however the game may not be stable due to the script no longer running as expected.
Title: Re: Invalid unitToAttackId in Island Survival Scenario
Post by: tomreyn on 30 December 2013, 16:12:41
Thanks for the improvement, Softcoder. I think if stability is likely to be impacted it may be better to force quit after the message has been read/confirmed. We would not want players to start / join another game after the fact and get disconnected in the middle of a game...
This said, if the message displayed there is clear enough about the stability issues then I don't think strictly forcing quit is needed.
Title: Re: Invalid unitToAttackId in Island Survival Scenario
Post by: softcoder on 30 December 2013, 23:46:38
The first part of such errors says: The game may no longer be stable!

Thanks
Title: Re: Invalid unitToAttackId in Island Survival Scenario
Post by: tomreyn on 31 December 2013, 12:06:42
Great, thanks (and sorry for not looking at what you committed)!