Page 1 of 1

[Oxyd] [1.0.0] Crash calling `request_path` with LuaEntity.bounding_box (PathFindAlgorithm check fails)

Posted: Tue Oct 06, 2020 2:23 pm
by totalnugget

Code: Select all

playerSurface.request_path{
      bounding_box = unit.bounding_box, 
      collision_mask = {"player-layer"}, 
      start = unit.position, 
      goal = next_pos, 
      force = game.players[event.player_index].force, 
      radius = 1,
      pathfind_flags = {prefer_straight_paths = true, cache = false, no_break = false},
      can_open_gates = true,
      path_resolution_modifier = -2,
      entity_to_ignore = unit
    }
This code can crash the game, if there is water between the start and goal.
changing the unit.bounding_box to unit.prototype.collision_box will make the function work as expected.

Log-file
factorio-current.log
(7.61 KiB) Downloaded 144 times

Re: [1.0.0] Crash calling `request_path` with LuaEntity.bounding_box (PathFindAlgorithm check fails)

Posted: Tue Oct 06, 2020 4:25 pm
by Klonan
Can you provide a save game with the specific unit setup?

Re: [1.0.0] Crash calling `request_path` with LuaEntity.bounding_box (PathFindAlgorithm check fails)

Posted: Tue Oct 06, 2020 6:33 pm
by totalnugget

Code: Select all

game.get_surface(1).request_path{
  bounding_box = {
    left_top = {
      x = -8.5625,
      y = 11.34765625
    },
    right_bottom = {
      x = -7.1640625,
      y = 12.74609375
    }
  },
  collision_mask = {"player-layer"}, 
  start = {-20, 0}, 
  goal = {70, 0}, 
  force = game.players[1].force, 
  radius = 1,
  pathfind_flags = {},
  can_open_gates = true,
  path_resolution_modifier = -2
}
running the above script on the map below (any map with enough water between the 2 positions works) will crash the game.
crash_map.zip
(1.03 MiB) Downloaded 138 times
the bounding box placed in the code above, was retrieved using bounding_box from a Unit prototype entity

full prototype data code below

Code: Select all

local car_base = util.copy(data.raw.car.car)
local gun_base = util.copy(data.raw["gun"]["vehicle-machine-gun"])
local ammo_base = util.copy(data.raw["ammo"]["piercing-rounds-magazine"])

gun_base.attack_parameters.ammo_type = ammo_base.ammo_type
gun_base.attack_parameters.animation = car_base.animation
local name = names.units.car

local car_unit = {

  type = "unit",
  name = name,
  localised_name = {name},
  icon = car_base.icon,
  icon_size = car_base.icon_size,
  flags = util.unit_flags(),
  map_color = {b = 0.5, g = 1},
  enemy_map_color = {r = 1},
  max_health = 315,
  radar_range = 2,
  order="i-c",
  subgroup = "transport",
  healing_per_tick = 0,
  collision_box = {{-0.7, -0.7}, {0.7, 0.7}},
  selection_box = {{-1.2, -1.2}, {1.2, 1.2}},
  collision_mask = util.ground_unit_collision_mask(),
  max_pursue_distance = 64,
  min_persue_time = (60 * 15),
  --sticker_box = {{-0.2, -0.2}, {0.2, 0.2}},
  distraction_cooldown = (30),
  move_while_shooting = true,
  can_open_gates = true,
  resistances =
  {
    {
      type = "acid",
      decrease = 8,
      percent = 60
    }
  },
  ai_settings =
  {
    do_separation = true
  },
  minable = {result = name, mining_time = 2},
  attack_parameters = gun_base.attack_parameters,
  vision_distance = 40,
  has_belt_immunity = true,
  movement_speed = 1,
  distance_per_frame = 0.15,
  pollution_to_join_attack = 1000,
  destroy_when_commands_fail = false,
  --corpse = name.." Corpse",
  dying_explosion = car_base.explosion,
  vehicle_impact_sound =  car_base.vehicle_impact_sound,
  working_sound = car_base.working_sound,
  run_animation = car_base.animation
}

Re: [1.0.0] Crash calling `request_path` with LuaEntity.bounding_box (PathFindAlgorithm check fails)

Posted: Tue Oct 06, 2020 6:42 pm
by Klonan
Alright, can confirm it crashes, nice one

Code: Select all

209355.088 Loading map C:\Factorio\saves\crash_map.zip: 1080792 bytes.
209355.242 Loading level.dat: 1121378 bytes.
209355.246 Info Scenario.cpp:190: Map version 1.0.0-0
209355.312 Verbose Scenario.cpp:233: Loading level.dat finished: 0.065652 seconds.
209355.314 Verbose BlueprintLibrary.cpp:66: Loaded external blueprint storage: playerIndex=0, nextRecordID=0, timestamp=1600196481, records={}
209355.338 Verbose Scenario.cpp:311: Entities setup finished: 0.025550 seconds.
209355.338 History step 0
209355.338   Version: 1.0.0 (build 54889)
209355.338   Mod Added: base 1.0.0
209355.338   Mod Added: debugadapter 0.18.26
209355.338   Mod Added: rts_mod 1.0.0
209355.338 History step 1
209355.338   Version: 1.1.0 (build 56027)
209355.338   Mod Updated: base 1.1.0
209355.338   Mod Removed: debugadapter 0.18.26
209355.338   Mod Removed: rts_mod 1.0.0
209355.340 Loading script.dat: 299 bytes.
209355.343 Checksum for script C:/Factorio/temp/currently-playing/control.lua: 327927728
209355.349 Info LuaGameScript.cpp:773: level state size: 103 bytes.
209355.349 Info LuaGameScript.cpp:773: level state size: 103 bytes.
209355.350 Verbose Scenario.cpp:355: Map setup finished: 0.262209 seconds.
209371.563 Time travel logging:
209371.560 Player 0 ran command: game.get_surface(1).request_path{   bounding_box = {     left_top = {       x = -8.5625,       y = 11.34765625     },     right_bottom = {       x = -7.1640625,       y = 12.74609375     }   },   collision_mask = {"player-layer"},    start = {-20, 0},    goal = {70, 0},    force = game.players[1].force,    radius = 1,   pathfind_flags = {},   can_open_gates = true,   path_resolution_modifier = -2 }
Factorio crashed. Generating symbolized stacktrace, please wait ...
c:\factorio\src\ai\pathfindalgorithm.cpp (1039): PathFindAlgorithm::expandBaseNode
c:\factorio\src\ai\pathfindalgorithm.cpp (617): PathFindAlgorithm::baseSearch
c:\factorio\src\ai\pathfindalgorithm.cpp (465): PathFindAlgorithm::update
c:\factorio\src\ai\pathfinder.cpp (399): PathFinder::update
c:\factorio\src\surface\surface.cpp (1580): Surface::update
c:\factorio\src\map\map.cpp (1697): Map::updateEntities
c:\factorio\src\map\map.cpp (1658): Map::update
c:\factorio\src\game.cpp (209): Game::update
c:\factorio\src\scenario\scenario.cpp (1236): Scenario::update
c:\factorio\src\scenario\scenario.cpp (1127): Scenario::updateStep
c:\factorio\src\mainloop.cpp (1188): MainLoop::gameUpdateStep
c:\factorio\src\mainloop.cpp (1053): MainLoop::gameUpdateLoop
c:\factorio\src\util\workerthread.cpp (49): WorkerThread::loop
c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\thr\xthread (230): std::_LaunchPad<std::unique_ptr<std::tuple<void (__cdecl WorkerThread::*)(void),WorkerThread *>,std::default_delete<std::tuple<void (__cdecl WorkerThread::*)(void),WorkerThread *> > > >::_Go
c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\thr\xthread (209): std::_Pad::_Call_func
minkernel\crts\ucrt\src\appcrt\startup\thread.cpp (115): thread_start<unsigned int (__cdecl*)(void * __ptr64)>
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FFBE0EE7BD4)
00007FFBE0EE7BD4 (KERNEL32): (filename not available): BaseThreadInitThunk
ERROR: SymGetLineFromAddr64, GetLastError: 487 (Address: 00007FFBE206CE51)
00007FFBE206CE51 (ntdll): (filename not available): RtlUserThreadStart
Stack trace logging done
209372.438 Error PathFindAlgorithm.cpp:1040: newChunkComponent->component != ChunkComponent::noComponent || newChunkComponent->chunk == ChunkPosition(current.position) was not true
Logger::writeStacktrace skipped.
209372.438 Error CrashHandler.cpp:189: Map tick at moment of crash: 3384
209372.438 C:\Factorio\bin\Releasex64vs2017\factorio-run.exe
209372.438 C:\Windows\SYSTEM32\ntdll.dll
209372.438 C:\Windows\System32\KERNEL32.DLL
209372.439 C:\Windows\System32\KERNELBASE.dll
209372.439 C:\Windows\System32\GDI32.dll
209372.439 C:\Windows\System32\win32u.dll
209372.439 C:\Windows\System32\gdi32full.dll
209372.439 C:\Windows\System32\msvcp_win.dll
209372.439 C:\Windows\System32\ucrtbase.dll
209372.439 C:\Windows\System32\USER32.dll
209372.439 C:\Windows\System32\ole32.dll
209372.439 C:\Windows\System32\combase.dll
209372.439 C:\Windows\System32\RPCRT4.dll
209372.439 C:\Windows\System32\bcryptPrimitives.dll
209372.439 C:\Windows\System32\advapi32.dll
209372.439 C:\Windows\System32\msvcrt.dll
209372.439 C:\Windows\System32\sechost.dll
209372.439 C:\Windows\System32\PSAPI.DLL
209372.439 C:\Windows\SYSTEM32\WINMM.dll
209372.439 C:\Windows\System32\SHELL32.dll
209372.439 C:\Windows\WinSxS\amd64_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.18362.1082_none_cf6c86c73eed9f8f\gdiplus.dll
209372.439 C:\Windows\System32\cfgmgr32.dll
209372.439 C:\Windows\SYSTEM32\winmmbase.dll
209372.439 C:\Windows\System32\shcore.dll
209372.439 C:\Windows\System32\windows.storage.dll
209372.439 C:\Windows\System32\profapi.dll
209372.439 C:\Windows\System32\powrprof.dll
209372.439 C:\Windows\System32\UMPDC.dll
209372.439 C:\Windows\System32\shlwapi.dll
209372.439 C:\Windows\System32\kernel.appcore.dll
209372.439 C:\Windows\System32\cryptsp.dll
209372.439 C:\Windows\System32\IMM32.dll
209372.439 C:\Windows\System32\OLEAUT32.dll
209372.439 C:\Windows\System32\CRYPT32.dll
209372.439 C:\Windows\System32\MSASN1.dll
209372.439 C:\Windows\System32\WS2_32.dll
209372.439 C:\Windows\System32\WINTRUST.dll
209372.439 C:\Windows\System32\imagehlp.dll
209372.439 C:\Windows\SYSTEM32\IPHLPAPI.DLL
209372.439 C:\Windows\System32\WLDAP32.dll
209372.439 C:\Windows\SYSTEM32\VERSION.dll
209372.439 C:\Windows\SYSTEM32\DSOUND.dll
209372.439 C:\Windows\system32\uxtheme.dll
209372.439 C:\Windows\SYSTEM32\dxgi.dll
209372.439 C:\Windows\SYSTEM32\dxcore.dll
209372.439 C:\Windows\SYSTEM32\d3d11.dll
209372.439 C:\Windows\SYSTEM32\d3d9.dll
209372.439 C:\Windows\SYSTEM32\dwmapi.dll
209372.439 C:\Windows\SYSTEM32\d3dcompiler_47.dll
209372.439 C:\Windows\System32\MSCTF.dll
209372.439 C:\Windows\System32\clbcatq.dll
209372.439 C:\Windows\system32\explorerframe.dll
209372.439 C:\Windows\SYSTEM32\WindowsCodecs.dll
209372.439 C:\Windows\System32\DriverStore\FileRepository\u0352369.inf_amd64_275818c45a90b362\B352355\aticfx64.dll
209372.439 C:\Windows\System32\DriverStore\FileRepository\u0352369.inf_amd64_275818c45a90b362\B352355\atiuxp64.dll
209372.439 C:\Windows\System32\DriverStore\FileRepository\u0352369.inf_amd64_275818c45a90b362\B352355\atidxx64.dll
209372.439 C:\Windows\System32\SETUPAPI.dll
209372.439 C:\Windows\System32\bcrypt.dll
209372.439 C:\Windows\SYSTEM32\apphelp.dll
209372.439 C:\Windows\SYSTEM32\amdihk64.dll
209372.439 C:\Windows\SYSTEM32\D3DSCache.dll
209372.439 C:\Windows\SYSTEM32\USERENV.dll
209372.439 C:\Windows\SYSTEM32\twinapi.appcore.dll
209372.439 C:\Windows\SYSTEM32\RMCLIENT.dll
209372.439 C:\Windows\SYSTEM32\dcomp.dll
209372.439 C:\Windows\System32\MMDevApi.dll
209372.439 C:\Windows\System32\DEVOBJ.dll
209372.439 C:\Windows\SYSTEM32\AUDIOSES.DLL
209372.439 C:\Windows\SYSTEM32\wintypes.dll
209372.439 C:\Windows\SYSTEM32\resourcepolicyclient.dll
209372.439 C:\Windows\System32\Windows.UI.dll
209372.439 C:\Windows\System32\TextInputFramework.dll
209372.439 C:\Windows\System32\InputHost.dll
209372.439 C:\Windows\System32\CoreUIComponents.dll
209372.439 C:\Windows\System32\CoreMessaging.dll
209372.439 C:\Windows\System32\PROPSYS.dll
209372.439 C:\Windows\SYSTEM32\ntmarta.dll
209372.439 C:\Windows\SYSTEM32\avrt.dll
209372.439 C:\Windows\SYSTEM32\mscms.dll
209372.439 C:\Windows\SYSTEM32\ColorAdapterClient.dll
209372.440 C:\Windows\SYSTEM32\icm32.dll
209372.440 C:\Windows\SYSTEM32\secur32.dll
209372.440 C:\Windows\SYSTEM32\SSPICLI.DLL
209372.440 C:\Windows\system32\mswsock.dll
209372.440 C:\Windows\SYSTEM32\iertutil.dll
209372.440 Error Util.cpp:97: Unexpected error occurred. If you're running the latest version of the game you can help us solve the problem by posting the contents of the log file on the Factorio forums.
Please also include the save file(s), any mods you may be using, and any steps you know of to reproduce the crash.

Re: [Oxyd] [1.0.0] Crash calling `request_path` with LuaEntity.bounding_box (PathFindAlgorithm check fails)

Posted: Tue Oct 06, 2020 7:40 pm
by boskid
facepalm

I noticed this crash at the same time when the "consider tile transition" pathfinder crash was happening which was around 0.17.79, there is even a test case written 9 months ago just for that, but it was disabled until it will be fixed and it was forgotten.

Basically the issue is because the bounding box does not contain the {0,0} point inside so different tile is checked for collisions than the tile for which component id is requested. As it does not contain {0,0} point, base node over the water may pass the collision check because there is terrain somewhere around and it will crash as there is no chunk component for tile itself. If you want temporary workaround, just do not use bounding boxes that do not contain the {0,0}.
staff

Re: [Oxyd] [1.0.0] Crash calling `request_path` with LuaEntity.bounding_box (PathFindAlgorithm check fails)

Posted: Tue Oct 27, 2020 4:18 pm
by Oxyd
Thanks, should be fixed in 1.1.0.