Author Topic: [Solved] Missing unit reference on a corpse leading to segfault?  (Read 358 times)

Offline krautbernd

  • Commander
  • *****
  • Posts: 1116
    • View Profile
Recently somebody reported a bug with a XCF save where killing the last alien on a map lead to a crash during recovery. As it turns out, a single corpse item was missing a unit reference which then somehow proceeded to crash the game:

Item ID 141 is a corpse missing an assigned unit:

Code: [Select]
    - id: 141
      type: STR_MEGASCORPION_CORPSE
      inventoryslot: STR_GROUND
      position: [33, 4, 0]
      droppedOnAlienTurn: true

Compare the next megascorpion corpse on the list:

Code: [Select]
    - id: 143
      type: STR_MEGASCORPION_CORPSE
      unit: 1000021
      inventoryslot: STR_GROUND
      position: [38, 23, 0]

Assigning a unit (even an existing one) to 141, e.g.

Code: [Select]
    - id: 141
      type: STR_MEGASCORPION_CORPSE
      unit: 1000021
      inventoryslot: STR_GROUND
      position: [33, 4, 0]
      droppedOnAlienTurn: true

Log:

Code: [Select]
[29-08-2023_18-08-29] [FATAL] A fatal error has occurred: Segmentation fault.
[29-08-2023_18-08-30] [FATAL] 0x5da620 OpenXcom::CrossPlatform::stackTrace(void*)
[29-08-2023_18-08-30] [FATAL] 0x5db490 OpenXcom::CrossPlatform::crashDump(void*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
[29-08-2023_18-08-30] [FATAL] 0x41c7f0 signalLogger(int)
[29-08-2023_18-08-30] [FATAL] 0xa100e0 OpenXcom::UfopaediaStartState::think()
[29-08-2023_18-08-30] [FATAL] 0x77bf653c _C_specific_handler
[29-08-2023_18-08-30] [FATAL] 0x77c0b340 _chkstk
[29-08-2023_18-08-30] [FATAL] 0x77bdf1d0 RtlInitializeResource
[29-08-2023_18-08-30] [FATAL] 0x77c0aa50 KiUserExceptionDispatcher
[29-08-2023_18-08-30] [FATAL] 0x8f13d0 OpenXcom::BattleUnit::getStatus() const
[29-08-2023_18-08-30] [FATAL] 0x555a20 OpenXcom::DebriefingState::recoverItems(std::vector<OpenXcom::BattleItem*, std::allocator<OpenXcom::BattleItem*> >*, OpenXcom::Base*)
[29-08-2023_18-08-30] [FATAL] 0x5574f0 OpenXcom::DebriefingState::prepareDebriefing()
[29-08-2023_18-08-30] [FATAL] 0x55ca90 OpenXcom::DebriefingState::init()
[29-08-2023_18-08-30] [FATAL] 0x5f2d40 OpenXcom::Game::run()
[29-08-2023_18-08-30] [FATAL] 0x41c950 SDL_main
[29-08-2023_18-08-30] [FATAL] 0xa11c10 console_main
[29-08-2023_18-08-30] [FATAL] 0xa11d30 WinMain
[29-08-2023_18-08-30] [FATAL] ??
[29-08-2023_18-08-30] [FATAL] ??
[29-08-2023_18-08-30] [FATAL] 0x77993de0 BaseThreadInitThunk
[29-08-2023_18-08-30] [FATAL] 0x77bf2930 RtlUserThreadStart
[29-08-2023_18-08-31] [FATAL] OpenXcom has crashed: Segmentation fault.

I have no idea what lead to the unit missing the reference, but is it intended behaviour to crash if a corpse item is (for whatever reason) missing a unit reference?

Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8570
    • View Profile
Re: MIssing unit reference on a corpse leading to segfault?
« Reply #1 on: August 30, 2023, 08:33:08 am »
Yes, it is "intended".

Each corpse must have a unit assigned.