2024-05-16 09:27 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002258Spring engineLuapublic2011-12-13 01:27
Reporteruser744 
Assigned ToKloot 
PrioritynormalSeveritycrashReproducibilityalways
StatusresolvedResolutionfixed 
Product Version0.82.6.1 
Target VersionFixed in Version85.0 
Summary0002258: Lua rules crashing spring.exe (UnitPreDamaged) in lauxlib.cpp:636
Descriptionwas working on my starcraft style resource harvesting gadget and spring.exe crashes due to a mistake in my lua code.

the new lines i had just add were line 73 to 76:

--no self damaging miners
if (is_miners[attackerID] and is_miners[unitID]) then
    return 0
    end
end


yes i know is_miners is a function and to call the function it should be is_miner(attackerID) instead of [ ] but yeah it still crashed the engine


tested a few times and the crash can be reproduced.
after the "resource unit" is attacked, the error message (see infolog) shows up for a moment in console, then spring.exe crashes.
Additional Informationinfolog.txt when it first crashed after /luarules reload
http://pastebin.ca/2017430

another infolog.txt
http://pastebin.ca/2017443

gadget:
http://pastebin.ca/2017432


maybe related to:
http://springrts.com/mantis/view.php?id=2161
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files

-Relationships
related to 0002161resolvedabma crash on /luarules reload while mod dev in UnitScript.cpp:226 
related to 0001877resolvedabma Crash in UnitScripts 
related to 0001908resolvedzerver SIGSEGV in UnitScript.cpp:232 
related to 0002079closed Conflict Terra crash 
related to 0002131closed 1v1 no AI conflict terra crash 
related to 0002156closed ct crash 
+Relationships

-Notes

~0006066

abma (administrator)

Translated:

E:\WINDOWS\system32\ntdll.dll 0x7C921E58 ??:0
E:\WINDOWS\system32\ntdll.dll 0x7C920D5C ??:0
E:\WINDOWS\system32\MSVCRT.dll 0x77BFC2DE ??:0
F:\Spiele\Spring_81\spring.exe 0xa6ec58 rts/lib/lua/src/lauxlib.cpp:636
F:\Spiele\Spring_81\spring.exe 0xa77a53 rts/lib/lua/src/lmem.cpp:83
F:\Spiele\Spring_81\spring.exe 0xa77545 rts/lib/lua/src/lfunc.cpp:156
F:\Spiele\Spring_81\spring.exe 0xa75924 rts/lib/lua/src/lgc.cpp:381
F:\Spiele\Spring_81\spring.exe 0xa75b72 rts/lib/lua/src/lgc.cpp:583
F:\Spiele\Spring_81\spring.exe 0xa75fd7 rts/lib/lua/src/lgc.cpp:618
F:\Spiele\Spring_81\spring.exe 0xa65e22 rts/lib/lua/src/lapi.cpp:469
F:\Spiele\Spring_81\spring.exe 0x5559f9 rts/Lua/LuaSyncedTable.cpp:75
F:\Spiele\Spring_81\spring.exe 0x55653a rts/Lua/LuaSyncedTable.cpp:115
F:\Spiele\Spring_81\spring.exe 0xa77118 rts/lib/lua/src/ldo.cpp:319
F:\Spiele\Spring_81\spring.exe 0xa77435 rts/lib/lua/src/ldo.cpp:376
F:\Spiele\Spring_81\spring.exe 0xa7216d rts/lib/lua/src/lvm.cpp:112
F:\Spiele\Spring_81\spring.exe 0xa735e9 rts/lib/lua/src/lvm.cpp:459
F:\Spiele\Spring_81\spring.exe 0xa77480 rts/lib/lua/src/ldo.cpp:377
F:\Spiele\Spring_81\spring.exe 0xa658a1 rts/lib/lua/src/lapi.cpp:822
F:\Spiele\Spring_81\spring.exe 0xa76c7b rts/lib/lua/src/ldo.cpp:119
F:\Spiele\Spring_81\spring.exe 0xa76cd9 rts/lib/lua/src/ldo.cpp:464
F:\Spiele\Spring_81\spring.exe 0xa656ea rts/lib/lua/src/lapi.cpp:843
F:\Spiele\Spring_81\spring.exe 0x664434 rts/Lua/LuaHandle.cpp:226
F:\Spiele\Spring_81\spring.exe 0x6645c4 rts/Lua/LuaHandle.cpp:255
F:\Spiele\Spring_81\spring.exe 0x66e65b rts/Lua/LuaHandle.h:362
F:\Spiele\Spring_81\spring.exe 0x96af97 rts/System/EventHandler.cpp:456
F:\Spiele\Spring_81\spring.exe 0x401d50 rts/Game/Game.cpp:2889
F:\Spiele\Spring_81\spring.exe 0x40eb23 rts/Game/Game.cpp:3216
F:\Spiele\Spring_81\spring.exe 0x986b16 rts/System/SpringApp.cpp:1072
F:\Spiele\Spring_81\spring.exe 0x991d39 rts/System/SpringApp.cpp:1182
F:\Spiele\Spring_81\spring.exe 0x992064 rts/System/Main.cpp:55
F:\Spiele\Spring_81\spring.exe 0x992840 rts/System/Main.cpp:91
F:\Spiele\Spring_81\spring.exe 0x4010a7 buildd/mingw32-runtime-3.15.2/build_dir/src/mingwrt-3.15.2-mingw32/crt1.c:237
F:\Spiele\Spring_81\spring.exe 0x401123 buildd/mingw32-runtime-3.15.2/build_dir/src/mingwrt-3.15.2-mingw32/crt1.c:271
E:\WINDOWS\system32\kernel32.dll 0x7C816FF7 ??:0

second translated:

E:\WINDOWS\system32\ntdll.dll 0x7C921E58 ??:0
E:\WINDOWS\system32\ntdll.dll 0x7C920D5C ??:0
E:\WINDOWS\system32\MSVCRT.dll 0x77BFC2DE ??:0
F:\Spiele\Spring_81\spring.exe 0xa6ec58 rts/lib/lua/src/lauxlib.cpp:636
F:\Spiele\Spring_81\spring.exe 0xa77a53 rts/lib/lua/src/lmem.cpp:83
F:\Spiele\Spring_81\spring.exe 0xa7432c rts/lib/lua/src/ltable.cpp:378
F:\Spiele\Spring_81\spring.exe 0xa7593f rts/lib/lua/src/lgc.cpp:383
F:\Spiele\Spring_81\spring.exe 0xa75b72 rts/lib/lua/src/lgc.cpp:583
F:\Spiele\Spring_81\spring.exe 0xa75fd7 rts/lib/lua/src/lgc.cpp:618
F:\Spiele\Spring_81\spring.exe 0xa73170 rts/lib/lua/src/lvm.cpp:706
F:\Spiele\Spring_81\spring.exe 0xa77480 rts/lib/lua/src/ldo.cpp:377
F:\Spiele\Spring_81\spring.exe 0xa658a1 rts/lib/lua/src/lapi.cpp:822
F:\Spiele\Spring_81\spring.exe 0xa76c7b rts/lib/lua/src/ldo.cpp:119
F:\Spiele\Spring_81\spring.exe 0xa76cd9 rts/lib/lua/src/ldo.cpp:464
F:\Spiele\Spring_81\spring.exe 0xa656ea rts/lib/lua/src/lapi.cpp:843
F:\Spiele\Spring_81\spring.exe 0x664434 rts/Lua/LuaHandle.cpp:226
F:\Spiele\Spring_81\spring.exe 0x6645c4 rts/Lua/LuaHandle.cpp:255
F:\Spiele\Spring_81\spring.exe 0x66e65b rts/Lua/LuaHandle.h:362
F:\Spiele\Spring_81\spring.exe 0x96af97 rts/System/EventHandler.cpp:456
F:\Spiele\Spring_81\spring.exe 0x401d50 rts/Game/Game.cpp:2889
F:\Spiele\Spring_81\spring.exe 0x40eb23 rts/Game/Game.cpp:3216
F:\Spiele\Spring_81\spring.exe 0x986b16 rts/System/SpringApp.cpp:1072
F:\Spiele\Spring_81\spring.exe 0x991d39 rts/System/SpringApp.cpp:1182
F:\Spiele\Spring_81\spring.exe 0x992064 rts/System/Main.cpp:55
F:\Spiele\Spring_81\spring.exe 0x992840 rts/System/Main.cpp:91
F:\Spiele\Spring_81\spring.exe 0x4010a7 buildd/mingw32-runtime-3.15.2/build_dir/src/mingwrt-3.15.2-mingw32/crt1.c:237
F:\Spiele\Spring_81\spring.exe 0x401123 buildd/mingw32-runtime-3.15.2/build_dir/src/mingwrt-3.15.2-mingw32/crt1.c:271
E:\WINDOWS\system32\kernel32.dll 0x7C816FF7 ??:0

~0006072

abma (administrator)

can you please test with current spring-master?

http://springrts.com/dl/buildbot/default/master/0.82.3-1044-g2642e75/spring_0.82.3-1044-g2642e75.exe

i couldn't reproduce the crash...

~0006073

abma (administrator)

or better: can you instructions how to reproduce in 0.82.6.1? which mod? ...?

~0006074

user744

ok i download the master .exe and will test later.
the mod is my work in progress mod thing.
sadly i did not make a copy of the .sdd folder as i was busy working on it and more concentrated on getting it work. will try to revert to a crashy version and upload the mod when i find a way to reproduce.

not sure if you noticed yet but maybe of interest:
if (is_miners[attackerID] and is_miners[unitID])

not only are [ ] used instead of ( ) but the function name is also misspelled: is_miner() and not is_miners().

~0006086

user744

tried to force it to crash again on the same thing but could not.
but crashed again on something else, crashes even in replay.

mod: (unpack as .sdd)
http://www.file-upload.net/download-3055405/Brickcraft.sdd_CRASHEDVERSION.zip.html

replay:
http://www.file-upload.net/download-3055406/CRASH20101217_032139_unnamed_0.82.6.sdf.html
(map is alien desert: http://www.springfiles.com/show_file.php?id=1422)

on the download site press the small button with the green arrow and dl will start without capture or countdown.

infolog.txt:
http://pastebin.ca/2021744
when watching the replay spring overwrote the original infolog but it looked similiar to this one from the replay.


Usually it does not crash, only in RARE cases when changing stuff and then doing /luarules reload
In this case the last thing i was editing was scripts\tpdrill.lua
in the RestoreAfterDelay() function:

Turn(drillhead, z_axis, 0, math.rad(50)) <- putting higher number for rotation speed
Turn(turretbase, y_axis, 0, math.rad(90)) <- putting higher number for rotation speed

I only did that editing towards the end of the replay (right before crash by /luarules reload) so the replay does not desync like it usually does when you watch a replay with edited mod.

Thinking of it, it seems only to crash when editing synced stuff ie I had never had it crash on /luaui reload or when editing widgets.

~0006087

user744

is there a way to try the spring master .exe without completly installing the engine? new spring installs always mess up my directories ;)

~0006088

user744

another crash, this time without /luarules reload
http://pastebin.ca/2021753

~0006089

user744

maybe of interest: the tp_mining.lua is basically the same as in conflict terra:
http://code.google.com/p/conflictterra/source/browse/games/CT/LuaRules/Gadgets/tp_mining.lua?r=898
afaik it has never crashed there.
differences are:
line 74, the --no self damaging miners

line 88, the --send cargo values to the unit scripts

and some smaller things like a different CEG effect.

just spend 2 minutes doing lots of /luarules reload with many units on screen and could not crash it. the only way i can always reproduce it atm is with the above replay.


btw similiar bug was:
http://springrts.com/mantis/view.php?id=2161

~0006091

abma (administrator)

Last edited: 2010-12-17 11:22

stacktrace is similar to 0002161!

both translated (identical stacktrace):

F:\Spiele\Spring_81\spring.exe 0x8da79b rts/Sim/Units/COB/UnitScript.cpp:223
F:\Spiele\Spring_81\spring.exe 0x8d1795 rts/Sim/Units/COB/UnitScriptEngine.cpp:81
F:\Spiele\Spring_81\spring.exe 0x40432e rts/Game/Game.cpp:3613
F:\Spiele\Spring_81\spring.exe 0x4237d6 rts/System/Sync/SyncChecker.h:40
F:\Spiele\Spring_81\spring.exe 0x42b400 rts/Game/Game.cpp:2832
F:\Spiele\Spring_81\spring.exe 0x9869f1 rts/System/SpringApp.cpp:1051
F:\Spiele\Spring_81\spring.exe 0x991d39 rts/System/SpringApp.cpp:1182
F:\Spiele\Spring_81\spring.exe 0x992064 rts/System/Main.cpp:55
F:\Spiele\Spring_81\spring.exe 0x992840 rts/System/Main.cpp:91
F:\Spiele\Spring_81\spring.exe 0x4010a7 buildd/mingw32-runtime-3.15.2/build_dir/src/mingwrt-3.15.2-mingw32/crt1.c:237
F:\Spiele\Spring_81\spring.exe 0x401123 buildd/mingw32-runtime-3.15.2/build_dir/src/mingwrt-3.15.2-mingw32/crt1.c:271
E:\WINDOWS\system32\kernel32.dll 0x7C816FF7 ??:0

~0006094

user744

could you reproduce the crash with the replay?

~0006096

user744

grmpf it is starting to annoy me. i had had hoped it would only happen on /luarules reload but that is not causing it.

what i tried:
-creating (both normal by building and /give ) lots of "tpdrill" units and just driving around the map -> so far no crash this way
-seems to crash mostly when tpdrill units start to attack but not always
-taking out the Spring.UnitScript.CallAsUnit in tp_mining.lua -> can still crash

~0006097

abma (administrator)

Last edited: 2010-12-17 22:00

do you use an ai while testing? the current release (0.82.6.1) has bugs in the ais, that corruptes memory, maybe this is the cause...

you can try the current 0.82-branch test build, it contains many fixes, especially about missing/damaged content files, 0.82.6.1 is sensitive about that. see 0002228 for more details.

currently i've no time to test if i can trigger a crash too, but your instructions should be enough.

maybe you could test a current build of the 0.82 branch (with the bugfixes), see http://springrts.com/phpbb/viewtopic.php?f=12&t=24406 for more details.

~0006098

user744

Last edited: 2010-12-17 23:29

ok, installed this version:
http://springrts.com/dl/buildbot/default/master/0.82.3-1044-g2642e75/spring_0.82.3-1044-g2642e75.exe
installed it as "portable", still it found one mod (xta 9.46) and around 5 maps. hm.
anyway, copied over my mod and tested:
-gives an error at gamestart when spawning startunits, unitlineage nil
-units are very dark, teamcolor still visible a bit
-when i ordered a tpdude unit to shot, spring crashed (never happend before in current)
infolog:
http://pastebin.ca/2022367

XTA has the same error of black units and crashed on moving the commander (he turned, made half a step - crash)
http://pastebin.ca/2022375

black commander in xta:
http://h-2.abload.de/img/screen0000009pw.png

units are not black if [x] reflective units is enabled

i always test over spring.exe without lobby, using the "Commanders" Script which does spawn an empty AI (dont know what kind)

~0006099

user744

Last edited: 2010-12-18 19:42

(I did further test with master because of the black units and it crashing even in xta)

tried giving the used units (tpdrill, tpkristall2) the "empty.lua" script in their unitdef and that seemed to be stable.
Then thought maybe the track animation of the tpdrill is causing it to crash and removed only that, crashed again.

Here is another version of the mod + replay:
http://www.file-upload.net/download-3057959/crashmod-v2.zip.html

infolog:
http://pastebin.ca/2022539
uploading because the adresses seem different.



edit:
made seperate ticket for the spring master crash:
http://springrts.com/mantis/view.php?id=2265

~0006104

Kloot (developer)

Last edited: 2010-12-18 22:08

The UnitScript.cpp crashes have been known for a while (see 1877, 1908, 2079, 2131, 2156). They are hard to pinpoint though.

~0006599

abma (administrator)

didn't see such crashes a long time... is this fixed?

~0006603

user744

i do not remember any such crashes since a while now.
but maybe just got lucky.

~0006604

abma (administrator)

ok, thx. please reopen if you'll unlucky ;-)

~0007863

user744

oh look, excactly one year later its that stupid gadget again.
Again error in lua -> spring.exe crashs unitpredamaged related.

[f=0008242] Error: LuaRules::RunCallIn: error = 2, UnitPreDamaged, [string "LuaRules/Gadgets/tp_mining.lua"]:196: attempt to index field '?' (a nil value)
stack traceback:
        [string "LuaRules/Gadgets/tp_mining.lua"]:196: in function 'UnitPreDamaged'
        [string "LuaGadgets/gadgets.lua"]:1330: in function <[string "LuaGadgets/gadgets.lua"]:1323>
        (tail call): ?
[f=0008242] Warning: UnitPreDamaged(): 1st value returned should be a number (newDamage)
[f=0008245] Warning: UnitPreDamaged(): 1st value returned should be a number (newDamage)
[f=0008246] Warning: UnitPreDamaged(): 1st value returned should be a number (newDamage)
[f=0008248] Error: LuaRules::RunCallIn: error = 5, UnitPreDamaged, error in error handling
[f=0008248] Warning: UnitPreDamaged(): 1st value returned should be a number (newDamage)
[f=0008248] Warning: UnitPreDamaged(): 2nd value returned should be a number (impulseMult)
[f=0008254] Warning: LuaRules stack check: top = -4
[f=0008982] Error: Spring 84.0 has crashed.

"full" infolog:
http://pastebin.com/YChg7NSn

gadget:
http://pastebin.com/TLkxAu4p
This version has checks added to protect against the nil, so line numbers are a bit different.
I kept the original line 196 as comment in line 200

~0007864

zerver (reporter)

FYI this bug:
[f=0008254] Warning: LuaRules stack check: top = -4
was introduced in Develop just few days ago and I'm currently working to resolve it.

~0007871

zerver (reporter)

CheckStack bug is fixed now, if you want to resume testing in develop

https://github.com/spring/spring/commit/e021d20b73d0fef374abb5f18b0c05761b362da3

~0007878

Kloot (developer)

actually fixed by jK
+Notes

-Issue History
Date Modified Username Field Change
2010-12-12 17:57 user744 New Issue
2010-12-12 18:49 abma Note Added: 0006066
2010-12-12 18:50 abma File Added: mining.lua
2010-12-12 18:59 abma Summary Lua rules crashing spring.exe (UnitPreDamaged) => Lua rules crashing spring.exe (UnitPreDamaged) in lauxlib.cpp:636
2010-12-13 20:45 abma Note Added: 0006072
2010-12-13 20:57 abma Note Added: 0006073
2010-12-13 23:19 user744 Note Added: 0006074
2010-12-17 03:42 user744 Note Added: 0006086
2010-12-17 03:46 user744 Note Added: 0006087
2010-12-17 03:53 user744 Note Added: 0006088
2010-12-17 04:04 user744 Note Added: 0006089
2010-12-17 11:18 abma Note Added: 0006091
2010-12-17 11:22 abma Note Edited: 0006091
2010-12-17 11:24 abma Relationship added related to 0002161
2010-12-17 17:49 user744 Note Added: 0006094
2010-12-17 21:43 user744 Note Added: 0006096
2010-12-17 21:59 abma Note Added: 0006097
2010-12-17 22:00 abma Note Edited: 0006097
2010-12-17 22:14 user744 Note Added: 0006098
2010-12-17 22:19 user744 Note Edited: 0006098
2010-12-17 22:46 user744 Note Edited: 0006098
2010-12-17 22:50 user744 Note Edited: 0006098
2010-12-17 23:29 user744 Note Edited: 0006098
2010-12-18 03:08 user744 Note Added: 0006099
2010-12-18 19:42 user744 Note Edited: 0006099
2010-12-18 22:08 Kloot Note Added: 0006104
2010-12-18 22:08 Kloot Note Edited: 0006104
2011-05-03 21:56 abma Note Added: 0006599
2011-05-03 21:56 abma Status new => feedback
2011-05-04 02:06 user744 Note Added: 0006603
2011-05-04 10:04 abma Relationship added related to 0001877
2011-05-04 10:04 abma Relationship added related to 0001908
2011-05-04 10:04 abma Relationship added related to 0002079
2011-05-04 10:04 abma Relationship added related to 0002131
2011-05-04 10:05 abma Relationship added related to 0002156
2011-05-04 10:07 abma Note Added: 0006604
2011-05-04 10:07 abma Status feedback => closed
2011-05-04 10:07 abma Resolution open => unable to reproduce
2011-12-12 13:45 user744 Note Added: 0007863
2011-12-12 13:45 user744 Status closed => feedback
2011-12-12 13:45 user744 Resolution unable to reproduce => reopened
2011-12-12 16:34 zerver Note Added: 0007864
2011-12-12 23:39 zerver Note Added: 0007871
2011-12-13 01:27 Kloot Note Added: 0007878
2011-12-13 01:27 Kloot Status feedback => resolved
2011-12-13 01:27 Kloot Fixed in Version => 85.0
2011-12-13 01:27 Kloot Resolution reopened => fixed
2011-12-13 01:27 Kloot Assigned To => Kloot
+Issue History