Author Topic: [FIXED] Seg fault on 2-stages mission (after aborting for 2nd stage)  (Read 5420 times)

Offline robin

  • Commander
  • *****
  • Posts: 1203
  • ULTIMATE ROOKIE
    • View Profile
I get a "Segmentation fault" (+crash) error when I abort to get to the 2nd stage of a 2-stages mission.
I'm using OXCE+ (but it does not mean the issue is related to OXCE+ stuff).
The crash happens specifically when aborting the 1st stage with soldiers on the target exit zone (to get to the 2nd stage with those soldiers).
Both missions by themselves are playable in Quick Battle mode, so the maps, terrain, itemSets, and deployment data, should be ok.

Any idea?

  - type: STR_ALIEN_GATE_LANDING  # 1st stage
    data:
      [...]
    width: 40
    length: 40
    height: 5
    terrains:
      - U_PLANET
    shade: 8
    markerName: STR_ALIEN_GATE
    markerIcon: 7
    genMission:
      STR_ALIEN_RETALIATION: 15
      STR_ALIEN_RAID_SMALL: 20
      STR_ALIEN_RAID_MEDIUM: 15
      STR_ALIEN_RAID_LARGE: 15
      STR_ALIEN_SUBVERSION: 15
      STR_ALIEN_SUPPLY: 20
    genMissionFreq: 3
    alienBase: true    # this is only to tell new battle mode what to do with this deployment
    nextStage: STR_ALIEN_GATE_ASSAULT
    briefing:
      textOffset: -16
      title: STR_ALIEN_GATE_MISSION
      desc: STR_ALIEN_GATE_LANDING_BRIEFING
      background: BACK01.SCR
      showTarget: false
    points: 5


  - type: STR_ALIEN_GATE_ASSAULT  # 2nd stage
    data:
      [...]
    width: 50
    length: 50
    height: 5
    terrains:
      - U_BUILDING
    shade: 15
    script: U_BUILDING
    briefing:
      textOffset: -16
      title: STR_ALIEN_GATE_MISSION
      desc: STR_ALIEN_GATE_ASSAULT_BRIEFING
      background: BACK01.SCR
      showTarget: false
    objectiveType: 40  # I have a item and a tile with specialType: 40
    alienBase: true    # this is only to tell new battle mode what to do with this deployment
    objectiveComplete: [STR_ALIEN_GATE_CONTROL_DESTROYED, 1000]
    objectivePopup: STR_CONTROL_CENTER_DESTROYED
« Last Edit: February 02, 2023, 03:00:54 pm by Meridian »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8596
    • View Profile
Re: Segmentation fault on 2-stages mission (after aborting for 2nd stage)
« Reply #1 on: April 02, 2017, 02:57:18 pm »
It might very well be OXCE+.
I have not tested 2-stage missions well, you could say almost not at all.

Could you share the current snapshot of your mod; and screenshot of quick battle settings (or better a save)?

Offline robin

  • Commander
  • *****
  • Posts: 1203
  • ULTIMATE ROOKIE
    • View Profile
Re: Segmentation fault on 2-stages mission (after aborting for 2nd stage)
« Reply #2 on: April 02, 2017, 03:27:49 pm »
mod: -deleted- tell me if you need it again

savegame attached (it's from a Quick Battle; you can just hit Abort->Ok to get the crash)

thanks
« Last Edit: April 02, 2017, 07:35:44 pm by robin »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8596
    • View Profile
Re: Segmentation fault on 2-stages mission (after aborting for 2nd stage)
« Reply #3 on: April 02, 2017, 04:14:14 pm »
It's most likely a code issue.

It works in vanilla.
It doesn't work in OXCE and OXCE+.
I'll ask Yankes for help.

Online Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: Segmentation fault on 2-stages mission (after aborting for 2nd stage)
« Reply #4 on: April 02, 2017, 04:42:47 pm »
I will look on this too.

Offline robin

  • Commander
  • *****
  • Posts: 1203
  • ULTIMATE ROOKIE
    • View Profile
Re: Segmentation fault on 2-stages mission (after aborting for 2nd stage)
« Reply #5 on: April 02, 2017, 07:36:02 pm »
Thank you both.

Online Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: Segmentation fault on 2-stages mission (after aborting for 2nd stage)
« Reply #6 on: April 03, 2017, 11:56:06 pm »
I find bug and solution, over all problem was because game try break connection of unit to old tiles that was destroyed by new map generation.
Fix is break this connection before old map is destroyed.
This will be fix in my next release.

in `BattlescapeGenerator::nextStage`:
Code: [Select]

+ // cleanup before map old map is destroyed
+ for (auto unit : *_save->getUnits())
+ {
+ unit->clearVisibleTiles();
+ unit->clearVisibleUnits();
+ }
+
  generateMap(script);

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: Segmentation fault on 2-stages mission (after aborting for 2nd stage)
« Reply #7 on: April 04, 2017, 02:35:48 am »
is that relevant to the master branch? is this something i also need to fix?

Online Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: Segmentation fault on 2-stages mission (after aborting for 2nd stage)
« Reply #8 on: April 04, 2017, 09:35:09 pm »
No, https://github.com/SupSuper/OpenXcom/blob/master/src/Battlescape/BattlescapeGenerator.cpp#L403 is fix for this situation too.
Difference was that OXCE used `clearVisibleTiles` that do more things that cause bug.

Offline robin

  • Commander
  • *****
  • Posts: 1203
  • ULTIMATE ROOKIE
    • View Profile
Re: Segmentation fault on 2-stages mission (after aborting for 2nd stage)
« Reply #9 on: April 13, 2017, 11:42:39 pm »
news on this fix?

Online Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: Segmentation fault on 2-stages mission (after aborting for 2nd stage)
« Reply #10 on: April 14, 2017, 01:01:16 am »
At least from my side I will release fix it week or two with new version. When Meridian will do it in his branch, I do not know. He could even faster because fix was posted in this thread.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8596
    • View Profile
Re: Segmentation fault on 2-stages mission (after aborting for 2nd stage)
« Reply #11 on: April 14, 2017, 06:31:06 pm »
news on this fix?

I will release a fix today evening.
Sorry for the delay... I was occupied by the Android version... but it's really time to make a break and switch back to PC version :)

EDIT: new version is up...
« Last Edit: April 14, 2017, 06:35:12 pm by Meridian »