Page 1 of 1

[Oxyd] Crash when using attack_area with group

Posted: Fri Sep 18, 2015 4:36 pm
by Doddler
I've been working on a mod, and ran into an issue where attempting to use attack_area on a group will cause the game to immediately crash. The general idea of the mod is to have biters that would normally not attack periodically (at night) form groups and attack stuff in the region with the highest pollution. The exact lua command that causes the crash is:

Code: Select all

group.set_command{ type=defines.command.attack_area, destination=game.player.position, radius=30, distraction=defines.distraction.by_anything }
Where in this case group is a group in which enemies have been assigned to it, and is verified to have at least one biter in it. Attempting to call the same command on individual biters rather than a group does work without issue.

For more context in which the code is executed, it looks like this:

Code: Select all

for _, biter in ipairs(game.get_surface(1).find_enemy_units(base, 16)) do
	group.add_member(biter)
end
if #group.members==0 then
	group.destroy()
else
	group.set_command{ type=defines.command.attack_area, destination=game.player.position, radius=30, distraction=defines.distraction.by_anything }
end
The log generated by the bug is as follows:

Code: Select all

Factorio crashed. Generating symbolized stacktrace, please wait ...
c:\temp\factorio-cb17afe1\libraries\stackwalker\stackwalker.cpp (923): StackWalker::ShowCallstack
c:\temp\factorio-cb17afe1\src\util\logger.cpp (283): Logger::writeStacktrace
c:\temp\factorio-cb17afe1\src\util\logger.cpp (337): Logger::logStacktrace
c:\temp\factorio-cb17afe1\src\util\crashhandler.cpp (81): CrashHandler::writeStackTrace
c:\temp\factorio-cb17afe1\src\util\crashhandler.cpp (90): CrashHandler::SehHandler
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FFAF48472B2)
00007FFAF48472B2 (KERNELBASE): (filename not available): UnhandledExceptionFilter
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FFAF750C028)
00007FFAF750C028 (ntdll): (filename not available): memset
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FFAF74F4516)
00007FFAF74F4516 (ntdll): (filename not available): _C_specific_handler
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FFAF75084CD)
00007FFAF75084CD (ntdll): (filename not available): _chkstk
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FFAF7477640)
00007FFAF7477640 (ntdll): (filename not available): RtlWalkFrameChain
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FFAF75075DA)
00007FFAF75075DA (ntdll): (filename not available): KiUserExceptionDispatcher
c:\temp\factorio-cb17afe1\src\surface\surface.cpp (298): Surface::findNearestEnemy
c:\temp\factorio-cb17afe1\src\ai\commandable.cpp (182): Commandable::checkDistractions
c:\temp\factorio-cb17afe1\src\ai\commandable.cpp (95): Commandable::runBehavior
c:\temp\factorio-cb17afe1\src\ai\commander.cpp (190): Commander::update
c:\temp\factorio-cb17afe1\src\surface\surface.cpp (806): Surface::update
c:\temp\factorio-cb17afe1\src\map\map.cpp (917): Map::update
c:\temp\factorio-cb17afe1\src\game.cpp (144): Game::update
c:\temp\factorio-cb17afe1\src\scenario\scenario.cpp (736): Scenario::update
c:\temp\factorio-cb17afe1\src\mainloop.cpp (253): MainLoop::gameUpdateStep
c:\temp\factorio-cb17afe1\src\mainloop.cpp (355): MainLoop::updateLoop
c:\boost_1_58_0\boost\function\function_template.hpp (160): boost::detail::function::void_function_obj_invoker0<boost::_bi::bind_t<void,void (__cdecl*)(ThreadBarrier * __ptr64,boost::chrono::time_point<boost::chrono::steady_clock,boost::chrono::duration<__int64,boost::ratio<1,1000000000> > > * __ptr64,boost::chrono::time_point<boost::chrono::steady_clock,boost::chrono::duration<__int64,boost::ratio<1,1000000000> > > * __ptr64,bool * __ptr64,bool),boost::_bi::list5<boost::_bi::value<ThreadBarrier * __ptr64>,boost::_bi::value<boost::chrono::time_point<boost::chrono::steady_clock,boost::chrono::duration<__int64,boost::ratio<1,1000000000> > > * __ptr64>,boost::_bi::value<boost::chrono::time_point<boost::chrono::steady_clock,boost::chrono::duration<__int64,boost::ratio<1,1000000000> > > * __ptr64>,boost::_bi::value<bool * __ptr64>,boost::_bi::value<bool> > >,void>::invoke
c:\temp\factorio-cb17afe1\src\util\thread.cpp (34): Thread::loop
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FF790525943)
00007FF790525943 (Factorio): (filename not available): boost::`anonymous namespace'::thread_start_function
f:\dd\vctools\crt\crtw32\startup\threadex.c (376): _callthreadstartex
f:\dd\vctools\crt\crtw32\startup\threadex.c (354): _threadstartex
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FFAF4F03622)
00007FFAF4F03622 (KERNEL32): (filename not available): BaseThreadInitThunk
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FFAF74B0784)
00007FFAF74B0784 (ntdll): (filename not available): RtlUserThreadStart
 213.194 Error Util.cpp:46: Unexpected error occurred. You can help us to solve the problem by posting the contents of the log file on the Factorio forums.

Re: [0.12.8] Crash when using attack_area with group

Posted: Mon Sep 21, 2015 12:33 pm
by Oxyd
Can't reproduce: Ran group.set_command{ type=defines.command.attack_area, destination=game.player.position, radius=30, distraction=defines.distraction.by_anything } on a non-empty group and it did not crash.

Re: [0.12.8] Crash when using attack_area with group

Posted: Wed Oct 07, 2015 6:45 pm
by Kyckyc
Oxyd wrote:Can't reproduce: Ran group.set_command{ type=defines.command.attack_area, destination=game.player.position, radius=30, distraction=defines.distraction.by_anything } on a non-empty group and it did not crash.
I Faced same bug.
Game version 12.10

This Crash related to this command, but to reproduce it, you need to call this command few times. Or maybe there is need to wait some time after execution to cause crash.
In my situation, i formed few groups of Biters every 400 ticks and sent them to player:

Code: Select all

group.set_command{ type=defines.command.attack_area, destination=game.player.position, radius=150, distraction=defines.distraction.by_anything }
First 5-15 commands works fine, but suddenly, next command will crash the game.


Here log:
https://drive.google.com/file/d/0B0DCzC ... sp=sharing

And you can use this tiny mod to reproduce (if you want):
https://drive.google.com/file/d/0B0DCzC ... sp=sharing

Re: [Oxyd] Crash when using attack_area with group

Posted: Thu Oct 08, 2015 10:41 am
by Oxyd
Thanks for the mod. This was caused by the game not handling empty unit groups well and crashing. Fixed in 0.12.11.