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

Pioneer crash at start #4174

Closed
Tichy opened this issue Oct 1, 2017 · 33 comments
Closed

Pioneer crash at start #4174

Tichy opened this issue Oct 1, 2017 · 33 comments

Comments

@Tichy
Copy link

Tichy commented Oct 1, 2017

After updating my local git repo, I compiled Pioneer but the new version crash as soon as it starts.
Visually I just see the window appear then disappear.

Launching from the terminal I obtain this:

ver git (8e90cc7f9) on: Linux

System Name: Linux
Host Name: ono-sendai
Release(Kernel) Version: 4.13.3-1-ARCH
Kernel Build Timestamp: #1 SMP PREEMPT Thu Sep 21 20:33:16 CEST 2017
Machine Arch: x86_64
Domain Name: (none)

SDL Version 2.0.6
Initialized OpenGL 3.1, with extensions, renderer
invalid axis binding '' in config file for BindAxisPitch
invalid axis binding '' in config file for BindAxisRoll
invalid axis binding '' in config file for BindAxisYaw
started 7 worker threads
ShipType::Init()
Lua::Init()
Fonts:
font orbiteer:
- DejaVuSans.ttf 1.200000
- wqy-microhei.ttc 1.000000
- Orbiteer-Bold.ttf 1.000000
font pionillium:
- DejaVuSans.ttf 0.928571
- wqy-microhei.ttc 1.000000
- PionilliumText22L-Medium.ttf 1.000000
import [libs/autoload.lua]: libs/autoload.lua did not return anything
import [ui/FileDialog.lua]: ui/FileDialog.lua did not return anything
Errore di segmentazione (core dump creato)

I tried to clone again from remote and compile, and I tried to rename my ~/.pioneer directory to exclude my settings.

My pioneer version (and OS):

ver git (8e90cc7)
Release(Kernel) Version: 4.13.3-1-ARCH
Kernel Build Timestamp: #1 SMP PREEMPT Thu Sep 21 20:33:16 CEST 2017
Machine Arch: x86_64
NVIDIA nasty proprietary drivers ver. 384.90
KDE Plasma 5.10 as DE

@ColdSpirit0
Copy link
Contributor

ColdSpirit0 commented Oct 2, 2017

Hmm... works good on my 4.12.13-1-ARCH. Tried to compile exact same version of pioneer and it runs without fails for me.
@Tichy, maybe path to pioneer directory have some no-english characters? If so, try to move it like to /data/pioneer/ and run from here.

If error still exists, please change line 172 at src/LuaUtils.cpp from #undef DEBUG_IMPORT to #define DEBUG_IMPORT, make again and put output here.

@Philbywhizz
Copy link
Contributor

I'm having a similar issue with the binary on OSX (compiles ok, blank white window on start and then fails). I've bisected the commit down to commit 5683029

@Tichy
Copy link
Author

Tichy commented Oct 2, 2017

Here's the full log after e enabling DEBUG_IMPORT

https://gist.github.com/Tichy/54d6ee4a816953b1a22522c18f01c056

@fluffyfreak
Copy link
Contributor

First thing @Tichy ono-sendai :D

Second thing @ColdSpirit0:

import [libs/autoload.lua]: file libs/autoload.lua loaded
import [libs/autoload.lua]: entering into cache... aborted because imported module returned nil
import [libs/autoload.lua]: generating error messages... got error: libs/autoload.lua did not return anything
import [libs/autoload.lua]: import status: fail

@Tichy
Copy link
Author

Tichy commented Oct 2, 2017

Heh... 😉

@jaj22
Copy link
Contributor

jaj22 commented Oct 2, 2017

I think the autoload.lua fail is working as intended. Returning nil is used as a signal that the lua file should not be used as an import.

However, there's an assumption in the import code that files will return exactly one value on the lua stack, while pi_lua_dofile will load files which return zero or multiple values. GalacticView.lua returns nothing, so the lua_isnil check is invalid there and so is the pop.

pi_lua_dofile, returns success with any number of return values:

static void pi_lua_dofile(lua_State *l, const FileSystem::FileData &code, int nret)

_import assuming single return value:

// usually happens when file not returns nothing or nil

@ColdSpirit0
Copy link
Contributor

ColdSpirit0 commented Oct 2, 2017

@Tichy thanks!

@fluffyfreak it common behaviour; for import it fail, but for caller it mabe ok. Also autoload.lua should not return anything, it is written in that file. Even if I tried to cache nil, I cant compare returned from cache element, it is not exists or 'nil' (not existing elements I getting like nil value).

@jaj22 thanks, I will check it tomorrow

That debug log from MacOS build (end of log):

import [Lang]: import started, caller: libs/Equipment.lua
import [Lang]: trying to load from cache... not cached
import [Lang]: trying to load a file...Assertion failed: (ty == FileInfo::FT_FILE), function ReadFile, file FileSystemPosix.cpp, line 158.

@jaj22
Copy link
Contributor

jaj22 commented Oct 2, 2017

The MacOS assert looks like a different issue. I can't find any documentation on stat_fd, which is a bad sign. I think fstat provides that functionality in POSIX.

@ColdSpirit0
Copy link
Contributor

ColdSpirit0 commented Oct 3, 2017

Stack trace from MacOS build:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	0x00007fff8a925f06 __pthread_kill + 10
1   libsystem_pthread.dylib       	0x00007fff941a54ec pthread_kill + 90
2   libsystem_c.dylib             	0x00007fff850786df abort + 129
3   libsystem_c.dylib             	0x00007fff8503fdd8 __assert_rtn + 321
4   pioneer                       	0x000000010990f07e FileSystem::FileSourceFS::ReadFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 718 (FileSystemPosix.cpp:158)
5   pioneer                       	0x00000001095e2361 FileSystem::FileSourceUnion::ReadFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 65 (.SmartPtr.h:33)
6   pioneer                       	0x0000000109659a44 load_file(lua_State*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 36 (LuaUtils.cpp:313)
7   pioneer                       	0x0000000109657921 _import(lua_State*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool) + 2705 (LuaUtils.cpp:352)
8   pioneer                       	0x00000001096584cd l_base_import(lua_State*) + 93 (LuaUtils.cpp:538)
9   pioneer                       	0x00000001098f4c86 luaD_precall + 534 (ldo.c:320)
10  pioneer                       	0x0000000109904f0a luaV_execute + 2970 (lvm.c:709)
11  pioneer                       	0x00000001098f5127 luaD_call + 71 (ldo.c:396)
12  pioneer                       	0x00000001098f4656 luaD_rawrunprotected + 86 (ldo.c:134)
13  pioneer                       	0x00000001098f5878 luaD_pcall + 56 (ldo.c:595)
14  pioneer                       	0x00000001098efe0a lua_pcallk + 234 (lapi.c:949)
15  pioneer                       	0x000000010965901f pi_lua_dofile(lua_State*, FileSystem::FileData const&, int) + 223 (LuaUtils.cpp:862)
16  pioneer                       	0x0000000109659a7b load_file(lua_State*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 91 (.SmartPtr.h:33)
17  pioneer                       	0x000000010965793f _import(lua_State*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool) + 2735 (LuaUtils.cpp:358)
18  pioneer                       	0x00000001096584cd l_base_import(lua_State*) + 93 (LuaUtils.cpp:538)

Also put here my log, without errors: pioneer.log

@ColdSpirit0
Copy link
Contributor

ColdSpirit0 commented Oct 3, 2017

@Tichy your log looks strange for me. It ends on 'success' and no errors after that. Maybe you miss something to copy?

Upd:

That should be after that success, but it does not output...

import [ui/GalacticView.lua]: file ui/GalacticView.lua loaded
import [ui/GalacticView.lua]: entering into cache... aborted because imported module returned nil
import [ui/GalacticView.lua]: generating error messages... got error: ui/GalacticView.lua did not return anything
import [ui/GalacticView.lua]: import status: fail
...

Made a diff of three logs (my, arch, macos) and see that I have only one thread,maybe that why all work on my system? How I can to enable more threads?
comparison

@jaj22
Copy link
Contributor

jaj22 commented Oct 3, 2017

FileDialog.lua also returns nothing (not nil, nothing), so the GalacticView import is already running with a corrupted lua stack. I wouldn't worry about exactly why it's crashing after that. It's inevitable.

@Tichy
Copy link
Author

Tichy commented Oct 3, 2017

@ColdSpirit0 I launched pioneer from both the installed package and the build directory. I can't be sure, but I tend to think that to have something missing I had to delete it myself. In the last test I did nothing but change the #define, make and launch ./pioneer from the src directory.

@ColdSpirit0
Copy link
Contributor

ColdSpirit0 commented Oct 3, 2017

@Tichy ok then, I just asked to be sure)

@jaj22 Im asking for 1 return parameter, I guess pi_lua_dofile puts exact one value, no matter how much values returned .lua file (if no returns, then nil).

pi_lua_dofile(L, *fileData, 1);

Im does not see any logic mistakes in that part of code, but by logs seems it is there.

Bad thing I cant reproduce that errors on my system, just dont know how. Tried to enable any debug flags, but I got lost in 'configure' file.

Upd:

No, debug flags will no help. I edited defines in cpp code and all checks passed.

I will try to install pioneer from AUR...
One more log here: https://aur.archlinux.org/packages/pioneer/
And here: https://aur.archlinux.org/packages/pioneer-git/

Upd 2:

Installed game from https://aur.archlinux.org/packages/pioneer-git/ and all works good.

@impaktor
Copy link
Member

impaktor commented Oct 3, 2017

I'm not following this bug, but was asked for a bt, so here goes (latest master, a3aeead):

font pionillium:
- DejaVuSans.ttf 0.928571
- wqy-microhei.ttc 1.000000
- PionilliumText22L-Medium.ttf 1.000000
import [libs/autoload.lua]: libs/autoload.lua did not return anything
import [ui/FileDialog.lua]: ui/FileDialog.lua did not return anything

Thread 1 "pioneer" received signal SIGSEGV, Segmentation fault.
0x00007ffff73f259a in ?? () from /usr/lib/libSDL2-2.0.so.0
(gdb) bt
#0  0x00007ffff73f259a in ?? () from /usr/lib/libSDL2-2.0.so.0
#1  0x00005555557b2eba in Graphics::TextureBuilder::PrepareSurface (this=this@entry=0x7fffffffd390) at TextureBuilder.cpp:117
#2  0x00005555558b3e3e in Graphics::TextureBuilder::GetDescriptor (this=0x7fffffffd390) at ./../graphics/TextureBuilder.h:48
#3  Graphics::TextureBuilder::CreateTexture (r=0x555555f80770, this=0x7fffffffd390) at ./../graphics/TextureBuilder.h:85
#4  Graphics::TextureBuilder::GetOrCreateTexture (type="ui", r=0x555555f80770, this=0x7fffffffd390) at ./../graphics/TextureBuilder.h:57
#5  UI::Image::Image (this=0x555556e21050, context=<optimized out>, filename=..., sizeControlFlags=12) at Image.cpp:28
#6  0x00005555558e35b4 in UI::Context::Image (sizeControlFlags=12, filename="galaxy_colour.png", this=0x555556ee1260) at ./../ui/Context.h:94
#7  GameUI::GalaxyMap::GalaxyMap (this=0x55555691d730, context=0x555556ee1260) at GalaxyMap.cpp:29
#8  0x00005555558dffb3 in GameUI::LuaGalaxyMap::l_new (l=<optimized out>) at LuaGalaxyMap.cpp:18
#9  0x00005555559730c5 in luaD_precall (L=L@entry=0x555556bbb100, func=<optimized out>, func@entry=0x55555758e220, nresults=nresults@entry=1) at ldo.c:318
#10 0x0000555555981da2 in luaV_execute (L=L@entry=0x555556bbb100) at lvm.c:709
#11 0x000055555597378e in luaD_call (L=0x555556bbb100, func=<optimized out>, nResults=<optimized out>, allowyield=<optimized out>) at ldo.c:395
#12 0x000055555597269f in luaD_rawrunprotected (L=0x555556bbb100, f=0x55555596ab80 <f_call>, ud=0x7fffffffd810) at ldo.c:131
#13 0x0000555555973bd3 in luaD_pcall (L=L@entry=0x555556bbb100, func=func@entry=0x55555596ab80 <f_call>, u=u@entry=0x7fffffffd810, old_top=96, ef=<optimized out>) at ldo.c:595
#14 0x000055555596ff55 in lua_pcallk (L=L@entry=0x555556bbb100, nargs=nargs@entry=0, nresults=nresults@entry=1, errfunc=errfunc@entry=5, ctx=ctx@entry=0, k=k@entry=0x0) at lapi.c:949
#15 0x0000555555692622 in pi_lua_dofile (l=l@entry=0x555556bbb100, code=..., nret=nret@entry=1) at LuaUtils.cpp:862
#16 0x0000555555693a08 in load_file (name="ui/GalacticView.lua", L=0x555556bbb100) at LuaUtils.cpp:316
#17 import_from_file (importInfo=<synthetic pointer>..., L=0x555556bbb100) at LuaUtils.cpp:349
#18 _import (L=L@entry=0x555556bbb100, importName="ui/GalacticView.lua", isFullName=isFullName@entry=true) at LuaUtils.cpp:484
#19 0x000055555569473e in pi_lua_import (isFullName=true, importName="ui/GalacticView.lua", L=0x555556bbb100) at LuaUtils.cpp:545
#20 pi_lua_import_recursive (L=L@entry=0x555556bbb100, basepath="ui") at LuaUtils.cpp:571
#21 0x00005555556b7e24 in LuaInit (this=<optimized out>, this=<optimized out>) at Pi.cpp:321
#22 Pi::Init (options=..., no_gui=<optimized out>) at Pi.cpp:577
#23 0x00005555555c0857 in main (argc=1, argv=<optimized out>) at main.cpp:128
(gdb) 

@fluffyfreak
Copy link
Contributor

@ColdSpirit0 open your config.ini and make sure that WorkerThreads=0 is set like that.
Do you have a multi-core CPU?
You can also set it to any number you like but by default Pioneer will set it to num_of_cores - 1 so that worker threads won't usually interfere with the main game thread.

Thread:
There appear to be a number of different issues going on here, Arch (Linux), MacOS and a graphics crash.

@ColdSpirit0
Copy link
Contributor

ColdSpirit0 commented Oct 3, 2017

@fluffyfreak thanks. Changing WorkerThreads have no effect to game stability.
Maybe all problems there have one reason)
Tichy and impaktor have same bug.

@scottyeager
Copy link

I'm also on Arch Linux and Pioneer started crashing after a system update, like so:

import [libs/autoload.lua]: libs/autoload.lua did not return anything
import [ui/FileDialog.lua]: ui/FileDialog.lua did not return anything
fish: 'pioneer' terminated by signal SIGSEGV (Address boundary error)

Downgrading from SDL version 2.0.6 back to 2.0.5 fixed this for me.

@laarmen
Copy link
Contributor

laarmen commented Oct 3, 2017 via email

@jaj22
Copy link
Contributor

jaj22 commented Oct 4, 2017

It's a deeper problem than UI code. With SDL 2.0.6, SDL_ConvertSurface is crashing on a simple RGB->RGBA conversion of galaxy_colour.png. I did wonder if the weird/broken surface format code in Pioneer was causing an upwards-compatibility problem, but apparently not.

It's likely that the bug isn't in Pioneer code. I'd need to replicate the issue locally with SDL debug libs to be sure.

The MacOS crash is unrelated. LuaUtils attempts to load imports as files before core, and ReadFile in FileSystemPosix.cpp is apparently opening the "data/lang" folder as import("Lang"). Best solution may be for ReadFile to check that it's not about to open a folder. It already has an assert for that, but it needs to handle arbitrary import names without falling over.

@fluffyfreak
Copy link
Contributor

Ah, SDL 2.0.6 was just released the other day.

@Tichy
Copy link
Author

Tichy commented Oct 4, 2017 via email

@fluffyfreak
Copy link
Contributor

fluffyfreak commented Oct 4, 2017

Yep it's definitely the SDL_ConvertSurface in SDL 2.0.6, I can get it to happen on Windows using VS2015.

EDIT: under debug (x64) I also get a crash using SDL_BlitSurface, oops it's actually SDL_SetSurfaceBlendMode loading the mouse cursor.

@mooskagh
Copy link

mooskagh commented Oct 4, 2017

Can anyone build/install a SDL with symbol information get a stack trace (which includes line numbers in libsdl)? I'll do that in ~6 hours, but maybe someone will have a chance to do that earlier?

@mooskagh
Copy link

mooskagh commented Oct 4, 2017

SDL part of stack trace:

#0  0x00007fd88c3048c6 in SDL_ConvertSurface_REAL (surface=0x55fe047c2840, format=0x55fe01f0a820, flags=0) at /home/crem/tmp/SDL2-2.0.6/src/video/SDL_surface.c:936
#1  0x00007fd88c24251a in SDL_ConvertSurface (a=0x55fe047c2840, b=0x55fe01f0a820, c=0) at /home/crem/tmp/SDL2-2.0.6/src/dynapi/SDL_dynapi_procs.h:492

Context of line 936:

 935     /* Save the original copy flags */
 936     copy_flags = surface->map->info.flags;
 937     copy_color.r = surface->map->info.r;

And surface->map is nullptr.

I'll look further in ~1 hour.

@mooskagh
Copy link

mooskagh commented Oct 4, 2017

Seems like a bug in SDL, which was fixed here https://bugzilla.libsdl.org/show_bug.cgi?id=3852 after 2.0.6 release.

UPD: and indeed applying https://hg.libsdl.org/SDL/rev/a09c3f87a12f fixes it.

@fluffyfreak
Copy link
Contributor

@mooskagh great work!
I'll have to wait for a point release with the fix before updating pioneer-thirdparty unless I wanna apply that patch and build DLLs/Libs for Windows versions.
Lets hope that they get it out fast too since at the moment I guess distro's are updating too a broken version.

@mooskagh
Copy link

mooskagh commented Oct 4, 2017

It's actually @jaj22 who did most of debugging, so credits should go to him. :)

There was a suggestion on #SDL to display a error message if we detect unpatched SDL 2.0.6, so that users pinged their distro maintainers to port the fix.

@jaj22
Copy link
Contributor

jaj22 commented Oct 4, 2017

@fluffyfreak

EDIT: under debug (x64) I also get a crash using SDL_BlitSurface, oops it's actually SDL_SetSurfaceBlendMode loading the mouse cursor.

I couldn't replicate this, so you may want to check whether it still happens with #4177. x64 crashes in the same place as x86 for me (with SDL 2.0.6).

@impaktor
Copy link
Member

impaktor commented Oct 5, 2017

@mooskagh / crem posted: https://discourse.libsdl.org/t/bug-3852-in-2-0-6/23182

regarding if we should expect a bugfix release.

@Tichy
Copy link
Author

Tichy commented Oct 6, 2017

Confirmed: all fine now 👍

@zonkmachine
Copy link
Member

@mooskagh / crem posted: https://discourse.libsdl.org/t/bug-3852-in-2-0-6/23182

regarding if we should expect a bugfix release.

SDL 2.0.7 in the works:
https://discourse.libsdl.org/t/sdl-2-0-7-prerelease/23232

@fluffyfreak
Copy link
Contributor

@zonkmachine thanks, I'll hold off updating the pioneer-thirdparty repo' until it's dropped then.

@zonkmachine
Copy link
Member

SDL version 2.0.7 is released:
https://www.libsdl.org/download-2.0.php

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

No branches or pull requests

10 participants