Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom systems segfault when you attempt to view them in the map #5857

Closed
a-random-lemurian opened this issue Jul 8, 2024 · 11 comments · Fixed by #5858
Closed

Custom systems segfault when you attempt to view them in the map #5857

a-random-lemurian opened this issue Jul 8, 2024 · 11 comments · Fixed by #5858

Comments

@a-random-lemurian
Copy link

a-random-lemurian commented Jul 8, 2024

Observed behaviour

Expected behaviour

I see the custom system in the view and I can spawn in it.

Steps to reproduce

  1. Put this system file in data/systems/custom: segfault-star.json
  2. Open Pioneer
  3. Ctrl+click new game
  4. (Try to) go to the coordinates 5, 5, 0 in the location menu
  5. Observe the segfault

My pioneer version (and OS):
Git commit d5e3147
Xubuntu 24.04

My output.txt (required) and game save (optional, but recommended)
output.txt

@impaktor
Copy link
Member

impaktor commented Jul 9, 2024

OK, so the crash is with a mod. Looks like pretty much every characteristic of that system has divide by zero?

Thread 1 "pioneer" received signal SIGSEGV, Segmentation fault.
0x00005555557cd3d0 in SectorMap::DrawNearSector (this=this@entry=0x555561934290, sx=5, sy=5, sz=0, trans=...) at /home/karlf/usr/src/pioneer/src/SectorMap.cpp:1027
1027			systrans.Scale((StarSystem::starScale[(*i).GetStarType(0)]));
(gdb) bt
#0  0x00005555557cd3d0 in SectorMap::DrawNearSector (this=this@entry=0x555561934290, sx=5, sy=5, sz=0, trans=...) at /home/karlf/usr/src/pioneer/src/SectorMap.cpp:1027
#1  0x00005555557cdb07 in SectorMap::DrawNearSectors (this=this@entry=0x555561934290, modelview=...) at /home/karlf/usr/src/pioneer/src/SectorMap.cpp:918
#2  0x00005555557cf322 in SectorMap::Draw3D (this=0x555561934290) at /home/karlf/usr/src/pioneer/src/SectorMap.cpp:614
#3  0x000055555562dd17 in SectorView::Draw3D (this=0x5555580140d0) at /usr/include/c++/14.1.1/bits/unique_ptr.h:193
#4  0x000055555561ad7a in GameLoop::Update (this=0x555555be3210, deltaTime=0.0170269571) at /home/karlf/usr/src/pioneer/src/Pi.cpp:1011
#5  0x00005555555ed4ef in Application::Run (this=0x555555be2fb0) at /home/karlf/usr/src/pioneer/src/core/Application.cpp:193
#6  0x00005555555e6504 in main (argc=<optimized out>, argv=<optimized out>) at /home/karlf/usr/src/pioneer/src/Pi.h:144

Where did you get this system from?

    "bodies": [
	{
	    "agricultural": "f0/0",
	    "argOfPeriapsis": "f0/0",
	    "aspectRatio": "f1/0",
	    "atmosColor": [
		0,
		0,
		0,
		255
	    ],
	    "atmosDensity": "f0/0",
	    "atmosOxidizing": "f0/0",
	    "averageTemp": 6908,
	    "axialTilt": "f0/0",
	    "eccentricity": "f0/0",
	    "hasRings": false,
	    "humanActivity": "f0/0",
	    "inclination": "f0/0",
	    "life": "f0/0",
	    "mass": "f0/0",
	    "metallicity": "f0/0",
	    "name": "Coredump",
	    "orbitalOffset": "f0/0",
	    "orbitalPhase": "f0/0",
	    "population": "f0/0",
	    "radius": "f0/0",
	    "rotationPeriod": "f0/0",
	    "rotationPhase": "f0/0",
	    "seed": 2,
	    "semiMajorAxis": "f0/0",
	    "type": "STAR_G",
	    "volatileIces": "f0/0",
	    "volatileLiquid": "f0/0",
	    "volcanicity": "f0/0"
	}
    ]

@zonkmachine
Copy link
Member

zonkmachine commented Jul 9, 2024

Warning: Caught error in Lua UI code:
	[T] pigui/views/map-sector-view.lua:224: bad argument #1 to 'text' (string expected, got nil)

Thread 1 "pioneer" received signal SIGSEGV, Segmentation fault.
0x0000555555981ab2 in ImDrawList::_CalcCircleAutoSegmentCount (this=0x55555b316700, radius=2.1545943e+09) at /home/zonkmachine/builds/pioneer/contrib/imgui/imgui_draw.cpp:572
572	        return _Data->CircleSegmentCounts[radius_idx]; // Use cached value
(gdb) bt full
#0  0x0000555555981ab2 in ImDrawList::_CalcCircleAutoSegmentCount (this=0x55555b316700, radius=2.1545943e+09) at /home/zonkmachine/builds/pioneer/contrib/imgui/imgui_draw.cpp:572
        radius_idx = -2147483648
#1  0x0000555555983a5a in ImDrawList::_PathArcToFastEx (this=0x55555b316700, center=..., radius=2.1545943e+09, a_min_sample=a_min_sample@entry=0, a_max_sample=a_max_sample@entry=48, a_step=a_step@entry=0)
    at /home/zonkmachine/builds/pioneer/contrib/imgui/imgui_draw.cpp:1066
        sample_range = <optimized out>
        a_next_step = <optimized out>
        samples = <optimized out>
        extra_max_sample = <optimized out>
        out_ptr = <optimized out>
        sample_index = <optimized out>
#2  0x0000555555986857 in ImDrawList::AddCircleFilled (num_segments=0, col=2147483647, radius=<optimized out>, center=..., this=0x55555b316700)
    at /home/zonkmachine/builds/pioneer/contrib/imgui/imgui_draw.cpp:1515
No locals.
#3  ImDrawList::AddCircleFilled (this=this@entry=0x55555b316700, center=..., radius=<optimized out>, col=2147483647, num_segments=num_segments@entry=0)
    at /home/zonkmachine/builds/pioneer/contrib/imgui/imgui_draw.cpp:1507
        a_max = <optimized out>
#4  0x00005555557c0f56 in SectorMap::StarLabel::Draw (this=0x55556c15b860, dl=..., hovered=<optimized out>) at /home/zonkmachine/builds/pioneer/src/SectorMap.cpp:146
        box = <optimized out>
        font = <optimized out>
#5  0x00005555557b8485 in SectorMap::DrawLabelsInternal (this=0x555556eabe00, interactive=<optimized out>, imagePos=...) at /home/zonkmachine/builds/pioneer/src/SectorMap.cpp:779
        hovered = @0x55556c15b860: {_vptr.Label = 0x555555b0cdc8 <vtable for SectorMap::StarLabel+16>, pos = {x = 639.999939, y = 359.999939, z = -0.0357779004}, color = 4291611852, host = @0x555556eac118}
        NOT_FOUND = <optimized out>
        hovered_i = 0
        drawData = {Valid = false, CmdListsCount = 1135968256, TotalIdxCount = 1432398800, TotalVtxCount = 21845, CmdLists = {Size = 1818829472, Capacity = 21845, 
    Data = 0x5555556d8870 <PiGui::Instance::NewFrame()+944>}, DisplayPos = {x = 2.77916261e+13, y = 3.0611365e-41}, DisplaySize = {x = 1.54392834e+13, y = 3.0611365e-41}, FramebufferScale = {x = 2.04011909e+17, y = 3.0611365e-41}, 
          OwnerViewport = 0x555555bcf7e0}
        dl = <optimized out>
#6  0x0000555555614cf3 in SectorView::DrawPiGui (this=<optimized out>) at /home/zonkmachine/builds/pioneer/src/SectorView.cpp:280
No locals.
#7  0x0000555555607fc2 in GameLoop::Update (this=0x555555bcf7e0, deltaTime=0.0166593846) at /home/zonkmachine/builds/pioneer/src/Pi.cpp:1039
        step = <optimized out>

@zonkmachine
Copy link
Member

Where did you get this system from?

I have a system like that and it's the .json version of sol00 created with the system editor. If I remove it I still get the segfault.

#0  0x0000555555981ab2 in ImDrawList::_CalcCircleAutoSegmentCount (this=0x55555c6efaf0, radius=2.21812864e+09) at /home/zonkmachine/builds/pioneer/contrib/imgui/imgui_draw.cpp:572
        radius_idx = -2147483648

@impaktor
Copy link
Member

impaktor commented Jul 9, 2024

@Web-eWorks any clue what's going on here?

@sturnclaw
Copy link
Member

Hmm... not off the top of my head, I'll have to take a look at it during the day sometime and dig into the crash. I did notice some weird behavior when I was loading a moderately complicated custom system I created on my own, but never got a chance to find the culprit (and it was having issues in mission Lua code, besides).

@a-random-lemurian
Copy link
Author

I remember just git cloning Pioneer and running cmake... is there a way to check for mods and remove them? I don't remember having any.

Also, I generated that with the system editor.

@impaktor
Copy link
Member

impaktor commented Jul 9, 2024

@a-random-lemurian The json system you provided is a mod, so you've made it or someone else, it's not in master.
Mods must be manually downloaded and installed from somewhere (usually a forum somewhere)

@a-random-lemurian
Copy link
Author

@a-random-lemurian The json system you provided is a mod, so you've made it or someone else, it's not in master. Mods must be manually downloaded and installed from somewhere (usually a forum somewhere)

So how do I check mods, if any, and remove them?

@sturnclaw
Copy link
Member

@a-random-lemurian how did you get the position of the star within the sector to be a negative value? It's not responsible for the crash, but the UI shouldn't let you do that directly.

The crash is a simple one - the system editor wasn't generating a needed piece of metadata (a list of stars in the system), and as a result the game thought the system had no stars. I've included some fixes to those conditions in an upcoming PR, so it should be a bit safer to run the game with a custom system that has no stars.

@sturnclaw
Copy link
Member

sturnclaw commented Jul 9, 2024

Specifically, the value of -11.568 should be impossible:
image

EDIT: ah, that would be because it's an uninitialized variable by default.

@sturnclaw
Copy link
Member

The issue should be fixed once the linked PR is merged. You'll need to load and re-save the system file for the fix to take effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants