pioneerspacesim / pioneer

A game of lonely space adventure
https://pioneerspacesim.net
1.64k stars 380 forks source link

Crashes when saving (flatpak) #5595

Closed the-ssd closed 11 months ago

the-ssd commented 1 year ago

Observed behaviour

Crash

Expected behaviour

Saved game

Steps to reproduce

1) start a new game 2) save

My pioneer version (and OS): (flatpak) 20230207 (Arch based Linux)

My output from console (last lines weren't in output.txt)

Info: ver 20230207 on: Linux
Info: System Name: Linux
Host Name: sergey-g752vt
Release(Kernel) Version: 6.4.3-arch1-1
Kernel Build Timestamp: #1 SMP PREEMPT_DYNAMIC Tue, 11 Jul 2023 05:13:39 +0000
Machine Arch: x86_64
Domain Name: (none)
Info: --------------------
Info: SDL Version (build) 2.24.0
Info: SDL Version (dynamic) 2.24.0
Info: SDL Versions match
Info: SDL_image Version (build): 2.6.2
Info: SDL_image Version (dynamic): 2.6.3
Info: WARNING: SDL_image Versions differ
Info: Assimp Version: 5.2.0
Info: FreeType Version: 2.12.1
Info: GLEW dynamic version: 2.1.0
Info: --------------------
Info: 
Info: Initialized OpenGL 3.1, with extensions, renderer
Info: Created shader vtxColor (address=0x5601b62ace20)
Info: Initializing joystick subsystem.
Info: font orbiteer:
Info: - Orbiteer-Bold.ttf 1.000000
Info: - DejaVuSans.ttf 1.200000
Info: - wqy-microhei.ttc 1.000000
Info: font pionillium:
Info: - PionilliumText22L-Medium.ttf 1.000000
Info: - DejaVuSans.ttf 0.928571
Info: - wqy-microhei.ttc 1.000000
Info: Created shader ui (address=0x5601b62aafd0)
Info: Created shader gen_gas_giant_colour (address=0x5601b62a8140)
Warning: Commodity rubbish has invalid producing economy ALL
Info: Loaded economy info: 3 economies, 31 commodities (10 consumable)
Info: started 7 worker threads in 0.85ms
Info: 

Engine startup took 259.69ms
Info: StartupScreen::Start()
Info: ShipType::Init()
Info: Lua::Init()
Info: Lua 5.2
Info: Loading [00%]: Sound::Init started
Info: Loading [00%]: Sound::Init took 19.42ms
Info: Loading [08%]: Lua::InitModules() started
Info: Ship Def found: malabar
Info: Ship Def found: missile_smart
Info: Ship Def found: ac33
Info: Ship Def found: sinonatrix_police
Info: Ship Def found: molaramsayi
Info: Ship Def found: storeria
Info: Ship Def found: wave
Info: Ship Def found: pumpkinseed_police
Info: Ship Def found: pumpkinseed
Info: Ship Def found: lunarshuttle
Info: Ship Def found: varada
Info: Ship Def found: xylophis
Info: Ship Def found: coronatrix
Info: Ship Def found: skipjack
Info: Ship Def found: missile_naval
Info: Ship Def found: coronatrix_police
Info: Ship Def found: kanara_civ
Info: Ship Def found: sinonatrix
Info: Ship Def found: missile_unguided
Info: Ship Def found: missile_guided
Info: Ship Def found: venturestar
Info: Ship Def found: vatakara
Info: Ship Def found: nerodia
Info: Ship Def found: natrix
Info: Ship Def found: lodos
Info: Ship Def found: kanara
Info: Ship Def found: molamola
Info: Ship Def found: bowfin
Info: Ship Def found: bluenose
Info: Ship Def found: dsminer
Info: Ship Def found: deneb
Info: 31
Info: Loading [08%]: Lua::InitModules() took 104.78ms
Info: Loading [17%]: GalaxyGenerator::Init() started
Info: Creating new galaxy generator 'legacy' version 1
Info: Warning: 'mass' is 0.000000 for body 'Themisto'
Info: Warning: 'mass' is 0.000000 for body 'Lucksmall'
Info: Number of factions added: 103
Info: StarSystemCache: misses: 0, slave hits: 0, master hits: 0
Info: SectorCache: misses: 101, slave hits: 0, master hits: 2
Info: Loading [17%]: GalaxyGenerator::Init() took 27.37ms
Info: Loading [25%]: FaceParts::Init() started
Info: Face Generation source images loaded.
Info: Loading [25%]: FaceParts::Init() took 2.47ms
Info: Loading [33%]: new ModelCache started
Info: Loading [33%]: new ModelCache took 0.00ms
Info: Loading [42%]: Shields::Init started
Info: Created shader shield (address=0x5601b7441b20)
Info: Loading [42%]: Shields::Init took 1.44ms
Info: Loading [50%]: BaseSphere::Init started
Info: GenerateIndices: triangles count = 648, mid indexes = 1728, hi edges = 54
Info: Loading [50%]: BaseSphere::Init took 90.94ms
Info: Loading [58%]: CityOnPlanet::Init started
Info: Loading city definition file 'configs/buildings/default.json'
Info: Created shader multi (address=0x5601b741cb70)
Info:   Created city definition flavour #1
Info: Loading [58%]: CityOnPlanet::Init took 188.70ms
Info: Loading [67%]: SpaceStation::Init started
Info: Created shader label (address=0x5601b796db00)
Info: ground_station has:
 14 entrances,
 14 pads,
 0 exits
Info: new_ground has:
 6 entrances,
 6 pads,
 0 exits
Info: orbital_station_2-10k has:
 5 entrances,
 64 pads,
 5 exits
Info: orbital_station_2-2k has:
 4 entrances,
 18 pads,
 4 exits
Info: orbital_station_2-5k has:
 5 entrances,
 64 pads,
 5 exits
Info: orbital_station_2-5k10k has:
 5 entrances,
 64 pads,
 5 exits
Info: Loading [67%]: SpaceStation::Init took 363.18ms
Info: Loading [75%]: NavLights::Init started
Info: Created shader billboards (address=0x5601b73bb730)
Info: Loading [75%]: NavLights::Init took 0.87ms
Info: Loading [83%]: Sfx::Init started
Info: Loading [83%]: Sfx::Init took 13.59ms
Info: Loading [92%]: PostLoad started
Info: Loading [92%]: PostLoad took 0.04ms
Info: 

Pioneer loading took 869.32ms
Info: Creating new galaxy generator 'legacy' version 1
Info: Clearing and re-using previous Galaxy object
Info: StarSystemCache: misses: 0, slave hits: 0, master hits: 0
Info: SectorCache: misses: 101, slave hits: 0, master hits: 1
Info: Created shader starfield (address=0x5601b710eb10)
Info: Stars picked from galaxy: 106058
Info: Generating 18942 random stars
Info: Final stars number: 125000
Info: Created shader skybox (address=0x5601b6e7e100)
Info: Created shader unlit (address=0x5601b7208030)
Info: Creating new galaxy generator 'legacy' version 1
Info: Clearing and re-using previous Galaxy object
Info: StarSystemCache: misses: 0, slave hits: 0, master hits: 0
Info: SectorCache: misses: 0, slave hits: 0, master hits: 0
Info: Stars picked from galaxy: 106058
Info: Generating 18942 random stars
Info: Final stars number: 125000
Info: Creating new galaxy generator 'legacy' version 1
Info: Clearing and re-using previous Galaxy object
Info: StarSystemCache: misses: 0, slave hits: 0, master hits: 0
Info: SectorCache: misses: 0, slave hits: 0, master hits: 0
Info: Stars picked from galaxy: 106058
Info: Generating 18942 random stars
Info: Final stars number: 125000
Info: Warning: Lua custom Systems definition: Surface starport has been automatically relocated. This is in order to place it on flatter ground to reduce the chance of landing pads being buried. This is not an error as such and you may attempt to move the starport to another location by changing latitude and longitude fields.
      Surface starport name: Cydonia, Body name: Mars, In sector: x = 0, y = 0, z = 0.
Info: Warning: Lua custom Systems definition: Surface starport has been automatically relocated. This is in order to place it on flatter ground to reduce the chance of landing pads being buried. This is not an error as such and you may attempt to move the starport to another location by changing latitude and longitude fields.
      Surface starport name: Tomm's Sanctuary, Body name: Deimos, In sector: x = 0, y = 0, z = 0.
Info: Warning: Lua custom Systems definition: Surface starport has been automatically relocated. This is in order to place it on flatter ground to reduce the chance of landing pads being buried. This is not an error as such and you may attempt to move the starport to another location by changing latitude and longitude fields.
      Surface starport name: Thebe Gas Refinery, Body name: Thebe, In sector: x = 0, y = 0, z = 0.
Info: Warning: Lua custom Systems definition: Surface starport has been automatically relocated. This is in order to place it on flatter ground to reduce the chance of landing pads being buried. This is not an error as such and you may attempt to move the starport to another location by changing latitude and longitude fields.
      Surface starport name: Pluto Research Base, Body name: Pluto, In sector: x = 0, y = 0, z = 0.
Info: Created shader sphereimpostor (address=0x5601be20cb40)
Info: Listening for headtracking packets on 127.0.0.1:4242
Info: WARNING: ship varada discarded, because there are no hyperspace routes available for it
Info: WARNING: lowering ships flow by 0.69 for performance reasons
Info: Created shader geosphere_terrain (address=0x5601c5f6d700)
Info: Created shader geosphere_sky (address=0x5601c5eb9e00)
/usr/include/c++/12.2.0/bits/stl_vector.h:1142: std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = unsigned int; _Alloc = std::allocator<unsigned int>; const_reference = const unsigned int&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.
d3rp commented 1 year ago

I had the same problem. The binary downloaded from the site seems to be a little dated (20230207). Building the game from the source files worked on my machine (note the latest fix for the release build, if you don't intend to use the debug build)

impaktor commented 1 year ago

A debug backtrace would help: https://wiki.pioneerspacesim.net/wiki/FAQ#Debug_backtrace

d3rp commented 1 year ago

Can't replicate this, but iirc it was the savefiles folder that was missing from ~/.pioneer/savefiles. Both directories supposedly have permissions 755.

There was also a commit to fix fedora(?) install having the wrong pioneer-data directory. Maybe related?

sandmuel commented 1 year ago

Also getting a crash on save (I'm on OpenSUSE, hope this helps :smile: ).

yump commented 1 year ago

Dupe of #5570.

ItsTheWhale commented 1 year ago

I also have this issue. The debug build from source works flawlessly though.

Console output:

Info: ver 20230207 on: Linux
Info: System Name: Linux
Host Name: void
Release(Kernel) Version: 6.5.7_1
Kernel Build Timestamp: #1 SMP PREEMPT_DYNAMIC Wed Oct 11 08:20:04 UTC 2023
Machine Arch: x86_64
Domain Name: (none)
Info: --------------------
Info: SDL Version (build) 2.24.0
Info: SDL Version (dynamic) 2.24.0
Info: SDL Versions match
Info: SDL_image Version (build): 2.6.2
Info: SDL_image Version (dynamic): 2.6.3
Info: WARNING: SDL_image Versions differ
Info: Assimp Version: 5.2.0
Info: FreeType Version: 2.12.1
Info: GLEW dynamic version: 2.1.0
Info: --------------------
Info: 
Info: Initialized OpenGL 3.1, with extensions, renderer
Info: Created shader vtxColor (address=0x560705d7d200)
Info: Initializing joystick subsystem.
Info: font orbiteer:
Info: - Orbiteer-Bold.ttf 1.000000
Info: - DejaVuSans.ttf 1.200000
Info: - wqy-microhei.ttc 1.000000
Info: font pionillium:
Info: - PionilliumText22L-Medium.ttf 1.000000
Info: - DejaVuSans.ttf 0.928571
Info: - wqy-microhei.ttc 1.000000
Info: Created shader ui (address=0x560705d75e80)
Info: Created shader gen_gas_giant_colour (address=0x56070675cb00)
Warning: Commodity rubbish has invalid producing economy ALL
Info: Loaded economy info: 3 economies, 31 commodities (10 consumable)
Info: started 11 worker threads in 0.37ms
Info: 

Engine startup took 78.62ms
Info: StartupScreen::Start()
Info: ShipType::Init()
Info: Lua::Init()
Info: Lua 5.2
Info: Loading [00%]: Sound::Init started
Info: Could not initialize SDL Audio: Could not setup connection to PulseAudio.
Info: Loading [00%]: Sound::Init took 3.37ms
Info: Loading [08%]: Lua::InitModules() started
Info: Ship Def found: molamola
Info: Ship Def found: coronatrix
Info: Ship Def found: xylophis
Info: Ship Def found: missile_guided
Info: Ship Def found: missile_smart
Info: Ship Def found: lodos
Info: Ship Def found: skipjack
Info: Ship Def found: nerodia
Info: Ship Def found: storeria
Info: Ship Def found: sinonatrix_police
Info: Ship Def found: varada
Info: Ship Def found: missile_unguided
Info: Ship Def found: vatakara
Info: Ship Def found: pumpkinseed_police
Info: Ship Def found: lunarshuttle
Info: Ship Def found: kanara
Info: Ship Def found: venturestar
Info: Ship Def found: dsminer
Info: Ship Def found: deneb
Info: Ship Def found: ac33
Info: Ship Def found: malabar
Info: Ship Def found: coronatrix_police
Info: Ship Def found: natrix
Info: Ship Def found: bluenose
Info: Ship Def found: molaramsayi
Info: Ship Def found: sinonatrix
Info: Ship Def found: kanara_civ
Info: Ship Def found: wave
Info: Ship Def found: missile_naval
Info: Ship Def found: pumpkinseed
Info: Ship Def found: bowfin
Info: 31
Info: Loading [08%]: Lua::InitModules() took 46.81ms
Info: Loading [17%]: GalaxyGenerator::Init() started
Info: Creating new galaxy generator 'legacy' version 1
Info: Warning: 'mass' is 0.000000 for body 'Themisto'
Info: Warning: 'mass' is 0.000000 for body 'Lucksmall'
Info: Number of factions added: 103
Info: StarSystemCache: misses: 0, slave hits: 0, master hits: 0
Info: SectorCache: misses: 101, slave hits: 0, master hits: 2
Info: Loading [17%]: GalaxyGenerator::Init() took 11.09ms
Info: Loading [25%]: FaceParts::Init() started
Info: Face Generation source images loaded.
Info: Loading [25%]: FaceParts::Init() took 1.28ms
Info: Loading [33%]: new ModelCache started
Info: Loading [33%]: new ModelCache took 0.00ms
Info: Loading [42%]: Shields::Init started
Info: Created shader shield (address=0x560706e36330)
Info: Loading [42%]: Shields::Init took 0.63ms
Info: Loading [50%]: BaseSphere::Init started
Info: GenerateIndices: triangles count = 648, mid indexes = 1728, hi edges = 54
Info: Loading [50%]: BaseSphere::Init took 33.37ms
Info: Loading [58%]: CityOnPlanet::Init started
Info: Loading city definition file 'configs/buildings/default.json'
Info: Created shader multi (address=0x560706d2a800)
Info:   Created city definition flavour #1
Info: Loading [58%]: CityOnPlanet::Init took 99.00ms
Info: Loading [67%]: SpaceStation::Init started
Info: Created shader label (address=0x560707028ba0)
Info: ground_station has:
 14 entrances,
 14 pads,
 0 exits
Info: new_ground has:
 6 entrances,
 6 pads,
 0 exits
Info: orbital_station_2-10k has:
 5 entrances,
 64 pads,
 5 exits
Info: orbital_station_2-2k has:
 4 entrances,
 18 pads,
 4 exits
Info: orbital_station_2-5k has:
 5 entrances,
 64 pads,
 5 exits
Info: orbital_station_2-5k10k has:
 5 entrances,
 64 pads,
 5 exits
Info: Loading [67%]: SpaceStation::Init took 324.93ms
Info: Loading [75%]: NavLights::Init started
Info: Created shader billboards (address=0x560706d1d350)
Info: Loading [75%]: NavLights::Init took 0.36ms
Info: Loading [83%]: Sfx::Init started
Info: Loading [83%]: Sfx::Init took 11.22ms
Info: Loading [92%]: PostLoad started
Info: Loading [92%]: PostLoad took 0.01ms
Info: 

Pioneer loading took 600.48ms
Info: Creating new galaxy generator 'legacy' version 1
Info: Clearing and re-using previous Galaxy object
Info: StarSystemCache: misses: 0, slave hits: 0, master hits: 0
Info: SectorCache: misses: 101, slave hits: 0, master hits: 1
Info: Created shader starfield (address=0x560706d1df20)
Info: Stars picked from galaxy: 106058
Info: Generating 18942 random stars
Info: Final stars number: 125000
Info: Created shader skybox (address=0x560707c21d80)
Info: Created shader unlit (address=0x560707891ad0)
Info: Creating new galaxy generator 'legacy' version 1
Info: Clearing and re-using previous Galaxy object
Info: StarSystemCache: misses: 0, slave hits: 0, master hits: 0
Info: SectorCache: misses: 0, slave hits: 0, master hits: 0
Info: Stars picked from galaxy: 106058
Info: Generating 18942 random stars
Info: Final stars number: 125000
Info: Creating new galaxy generator 'legacy' version 1
Info: Clearing and re-using previous Galaxy object
Info: StarSystemCache: misses: 0, slave hits: 0, master hits: 0
Info: SectorCache: misses: 0, slave hits: 0, master hits: 0
Info: Stars picked from galaxy: 106058
Info: Generating 18942 random stars
Info: Final stars number: 125000
Info: Creating new galaxy generator 'legacy' version 1
Info: Clearing and re-using previous Galaxy object
Info: StarSystemCache: misses: 0, slave hits: 0, master hits: 0
Info: SectorCache: misses: 0, slave hits: 0, master hits: 0
Info: Stars picked from galaxy: 106058
Info: Generating 18942 random stars
Info: Final stars number: 125000
Info: Warning: Lua custom Systems definition: Surface starport has been automatically relocated. This is in order to place it on flatter ground to reduce the chance of landing pads being buried. This is not an error as such and you may attempt to move the starport to another location by changing latitude and longitude fields.
      Surface starport name: Cydonia, Body name: Mars, In sector: x = 0, y = 0, z = 0.
Info: Warning: Lua custom Systems definition: Surface starport has been automatically relocated. This is in order to place it on flatter ground to reduce the chance of landing pads being buried. This is not an error as such and you may attempt to move the starport to another location by changing latitude and longitude fields.
      Surface starport name: Tomm's Sanctuary, Body name: Deimos, In sector: x = 0, y = 0, z = 0.
Info: Warning: Lua custom Systems definition: Surface starport has been automatically relocated. This is in order to place it on flatter ground to reduce the chance of landing pads being buried. This is not an error as such and you may attempt to move the starport to another location by changing latitude and longitude fields.
      Surface starport name: Thebe Gas Refinery, Body name: Thebe, In sector: x = 0, y = 0, z = 0.
Info: Warning: Lua custom Systems definition: Surface starport has been automatically relocated. This is in order to place it on flatter ground to reduce the chance of landing pads being buried. This is not an error as such and you may attempt to move the starport to another location by changing latitude and longitude fields.
      Surface starport name: Pluto Research Base, Body name: Pluto, In sector: x = 0, y = 0, z = 0.
Info: Created shader sphereimpostor (address=0x560706999900)
Info: Listening for headtracking packets on 127.0.0.1:4242
Info: WARNING: ship varada discarded, because there are no hyperspace routes available for it
Info: WARNING: lowering ships flow by 0.70 for performance reasons
Info: Created shader geosphere_terrain (address=0x56070d7e9840)
Info: Created shader geosphere_sky (address=0x56070da74990)
/usr/include/c++/12.2.0/bits/stl_vector.h:1142: std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = unsigned int; _Alloc = std::allocator<unsigned int>; const_reference = const unsigned int&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.
impaktor commented 1 year ago

Dupe of https://github.com/pioneerspacesim/pioneer/issues/5570.

So the bug is fixed on our side.

However, is the flatpak updated?

yump commented 1 year ago

It is not.

The flatpak is on the last tagged release from 2023 Feb 3. Fedora's package is cd91559, from 2023 Mar 1. Fix went in on 2023 Mar 22.

I dropped the ball here because #5534 made the game effectively unplayable and I burnt out trying to figure it out.

hexagonrecursion commented 11 months ago

My game also crashed when I tried to save it. Pioneer 20230203 (from flathub), OS: Fedora Here is the backtrace from gdb (thank god flathub provides a .Debug extension for pioneer)

#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007ffff7491273 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007ffff743f04e in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffff74287fc in __GI_abort () at abort.c:79
#4  0x00007ffff78e1f9d in std::__glibcxx_assert_fail (file=file@entry=0x555555a1c258 "/usr/include/c++/12.2.0/bits/stl_vector.h", line=line@entry=1142, 
    function=function@entry=0x555555a2b6c8 "std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = unsigned int; _Alloc = std::allocator<unsigned int>; const_reference = const unsigned int&; "..., condition=condition@entry=0x555555a1c004 "__n < this->size()") at ../../../../../libstdc++-v3/src/c++11/debug.cc:60
#5  0x00005555559d0ad3 in std::vector<unsigned int, std::allocator<unsigned int> >::operator[] (this=<optimized out>, __n=<optimized out>) at /usr/include/c++/12.2.0/bits/stl_vector.h:1142
#6  std::vector<unsigned int, std::allocator<unsigned int> >::operator[] (this=<optimized out>, __n=<optimized out>) at /usr/include/c++/12.2.0/bits/stl_vector.h:1140
#7  PropertyMap::iterator::operator++ (this=this@entry=0x7fffffffcb90) at /run/build/pioneer/src/core/Property.cpp:118
#8  0x00005555559d362d in PropertyMap::SaveToJson (this=this@entry=0x55555ca182a8, obj=...) at /run/build/pioneer/src/core/Property.cpp:166
#9  0x000055555579d62e in Body::SaveToJson (this=0x55555ca18290, jsonObj=..., space=0x555556f54350) at /run/build/pioneer/src/Body.cpp:80
#10 0x00005555556ba9a6 in TerrainBody::SaveToJson (this=0x55555ca18290, jsonObj=..., space=0x555556f54350) at /run/build/pioneer/src/TerrainBody.cpp:45
#11 0x000055555569fc27 in Space::ToJson (this=0x555556f54350, jsonObj=...) at /run/build/pioneer/src/Space.cpp:344
#12 0x00005555557c3f49 in Game::ToJson (this=0x555556f8a6b0, jsonObj=...) at /run/build/pioneer/src/Game.cpp:217
#13 0x00005555557c69bb in Game::SaveGame (filename="1", game=0x555556f8a6b0) at /run/build/pioneer/src/Game.cpp:924
#14 0x00005555558bfea6 in l_game_save_game (l=0x555555be9af0) at /run/build/pioneer/src/lua/LuaGame.cpp:253
#15 0x00005555559296eb in luaD_precall (L=L@entry=0x555555be9af0, func=<optimized out>, func@entry=0x555562334030, nresults=nresults@entry=0) at /run/build/pioneer/contrib/lua/src/ldo.c:318
#16 0x0000555555938c05 in luaV_execute (L=L@entry=0x555555be9af0) at /run/build/pioneer/contrib/lua/src/lvm.c:709
#17 0x0000555555929a98 in luaD_call (L=0x555555be9af0, func=<optimized out>, nResults=<optimized out>, allowyield=<optimized out>) at /run/build/pioneer/contrib/lua/src/ldo.c:395
#18 0x0000555555928ff6 in luaD_rawrunprotected (L=L@entry=0x555555be9af0, f=f@entry=0x55555591f640 <f_call>, ud=ud@entry=0x7fffffffd410) at /run/build/pioneer/contrib/lua/src/ldo.c:131
#19 0x0000555555929d19 in luaD_pcall (L=L@entry=0x555555be9af0, func=func@entry=0x55555591f640 <f_call>, u=u@entry=0x7fffffffd410, old_top=592, ef=<optimized out>) at /run/build/pioneer/contrib/lua/src/ldo.c:595
#20 0x00005555559220d1 in lua_pcallk (L=L@entry=0x555555be9af0, nargs=nargs@entry=0, nresults=nresults@entry=-1, errfunc=errfunc@entry=1, ctx=ctx@entry=0, k=k@entry=0x555555925a80 <pcallcont>)
    at /run/build/pioneer/contrib/lua/src/lapi.c:949
#21 0x0000555555925a48 in luaB_xpcall (L=0x555555be9af0) at /run/build/pioneer/contrib/lua/src/lbaselib.c:405
#22 0x00005555559296eb in luaD_precall (L=L@entry=0x555555be9af0, func=<optimized out>, func@entry=0x555562333e00, nresults=nresults@entry=-1) at /run/build/pioneer/contrib/lua/src/ldo.c:318
#23 0x0000555555938bad in luaV_execute (L=L@entry=0x555555be9af0) at /run/build/pioneer/contrib/lua/src/lvm.c:723
#24 0x0000555555929a98 in luaD_call (L=0x555555be9af0, func=<optimized out>, nResults=<optimized out>, allowyield=<optimized out>) at /run/build/pioneer/contrib/lua/src/ldo.c:395
#25 0x0000555555928ff6 in luaD_rawrunprotected (L=L@entry=0x555555be9af0, f=f@entry=0x55555591f640 <f_call>, ud=ud@entry=0x7fffffffd6e0) at /run/build/pioneer/contrib/lua/src/ldo.c:131
#26 0x0000555555929d19 in luaD_pcall (L=L@entry=0x555555be9af0, func=func@entry=0x55555591f640 <f_call>, u=u@entry=0x7fffffffd6e0, old_top=336, ef=<optimized out>) at /run/build/pioneer/contrib/lua/src/ldo.c:595
#27 0x00005555559220d1 in lua_pcallk (L=0x555555be9af0, nargs=<optimized out>, nresults=1, errfunc=<optimized out>, ctx=<optimized out>, k=<optimized out>) at /run/build/pioneer/contrib/lua/src/lapi.c:949
#28 0x000055555591e6b9 in pi_lua_protected_call (L=L@entry=0x555555be9af0, nargs=nargs@entry=1, nresults=nresults@entry=1) at /run/build/pioneer/src/lua/core/Sandbox.cpp:253
#29 0x000055555571ca70 in LuaTable::Call<bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, double> (key="game", this=0x7fffffffd7a0) at /run/build/pioneer/src/lua/LuaTable.h:402
#30 PiGui::RunHandler (delta=0.026979612186551094, handler="game") at /run/build/pioneer/src/pigui/LuaPiGui.cpp:85
#31 0x0000555555646b18 in GameLoop::Update (this=0x555555bd63e0, deltaTime=0.0269796122) at /usr/include/c++/12.2.0/bits/new_allocator.h:80
#32 0x00005555555f5eb4 in Application::Run (this=0x555555bd5ff0) at /run/build/pioneer/src/core/Application.cpp:192
#33 0x00005555555d528c in main (argc=1, argv=<optimized out>) at /run/build/pioneer/src/main.cpp:186

This is the code that broke: https://github.com/pioneerspacesim/pioneer/blob/e77da966923a4ad24c8863bcca7dec7933c33d43/src/core/Property.cpp#L114-L121

You tried to access 1 past the end of m_keys.

Proposed fix:

 PropertyMap::iterator PropertyMap::iterator::operator++() 
 { 
    size_t sz = map->m_keys.size(); 
    if (map) 
        while (idx < sz && !map->m_keys[++idx]) { 
        } 
    return *this; 
 }

Other issues with this code:

  1. You check if (map) too late. I do not know if map can be NULL, but if it can undefined behaviour occurs in map->m_keys.size(). Fix:
    PropertyMap::iterator PropertyMap::iterator::operator++() 
    { 
        if (map) {
            size_t sz = map->m_keys.size();
            while (idx < sz && !map->m_keys[++idx]) { 
            } 
        }
        return *this; 
    }
  2. I see no valid use-case for map to ever be NULL. If it can never be NULL, I would recommend using a reference instead of a pointer. Than no NULL checks will be necessary.
hexagonrecursion commented 11 months ago

Wait! No! Bad fix. Still goes out of bounds. A good fix is already in master, https://github.com/pioneerspacesim/pioneer/commit/a1e93056c999998b46e2176f71464117e7ffec09. As far as I understand flathub usually only hosts releases. The fix can theoretically be backported and applied as a "patch" when building flatpak if you do not plan to make a release soon, but I would probably make a hotfix release instead if I were you.

impaktor commented 11 months ago

@hexagonrecursion we plan release in 2 months, February 3rd.

hexagonrecursion commented 11 months ago

Just for fun I fixed this on my machine by patching the binary - it's just a one-byte patch.

# WARNING: only apply the fix if sha256 hash of the file you are patching matches EXACTLY.
sha256sum < ~/.local/share/flatpak/app/net.pioneerspacesim.Pioneer/current/active/files/bin/pioneer
9278f6dd38ac5d810d000999dbbd306e6da7e9c7287cb68374976efac2faaf9d  -
echo -ne '\x0a' | dd of=~/.local/share/flatpak/app/net.pioneerspacesim.Pioneer/current/active/files/bin/pioneer obs=1 seek=4704925 conv=notrunc
# Here is what the hash should be if you applied the patch correctly
sha256sum < ~/.local/share/flatpak/app/net.pioneerspacesim.Pioneer/current/active/files/bin/pioneer
411a25b25074f98f25802a1d62368e89e049bac6b1c24a557b7e01614ef3ae79  -

In more constructive news: I'll ask flathub people whether they accept a source patch as a stopgap until the next release of pioneer. This bug is kind of a show-stopper.

impaktor commented 11 months ago

Yeah, would be great if it was fixed on flathub side. (I don't know if our flathub maintainer @pcercuei want to be in the loop)

pcercuei commented 11 months ago

https://github.com/flathub/net.pioneerspacesim.Pioneer/pull/7

impaktor commented 11 months ago

Thanks for fixing it!