MCPI-Revival / Ninecraft

A mcpe 0.1.0-0.10.5 launcher for linux
MIT License
59 stars 4 forks source link

Arch Linux: segfaults after displaying MCPE version (built from master) #12

Open zaafonin opened 1 year ago

zaafonin commented 1 year ago

After installing all listed dependencies, compiling Ninecraft (with debug build type) and doing extract.sh on a x86 apk of 0.8.1, Ninecraft briefly shows a black window and segfaults:

[AUDIO_ENGINE] Failed to open device
lib: /home/zaafonin/Downloads/Ninecraft/lib/x86/libminecraftpe.so: : 0x56738ce0
Ninecraft is running mcpe v0.8.1
Segmentation fault (core dumped)

Fixing the audio (btw, I'd add lib32-libpulse to readme as OpenAL still uses it) didn't change much except for the first line not being present, and the window showing up for just a little longer.

Same thing happens with 0.7.6 and 0.6.1. Not familiar with MCPE internals atm, so can't figure out what might be wrong.

zaafonin commented 1 year ago

0.5.0 produces a slightly different result:

Vsize: 24, 24
lib: /home/zaafonin/Downloads/Ninecraft/lib/x86/libminecraftpe.so: : 0x56742ce0
Ninecraft is running mcpe v0.5.0
4.6 (Compatibility Profile) Mesa 23.1.1
nine construct 0xd43bccc0
0xffdb46d0
debug: AppPlatform_linux::isPowerVR
debug: AppPlatform_linux::readAssetFile
Segmentation fault (core dumped)

, so something's definitely happening

zaafonin commented 1 year ago

Done a GDB on ninecraft executable:

``` Thread 1 "ninecraft" received signal SIGSEGV, Segmentation fault. 0xf786a725 in _XSend (dpy=0x5667ec50, data=0x0, size=0) at /usr/src/debug/lib32-libx11/libX11-1.8.5/src/xcb_io.c:569 569 requests = dpy_request - dpy->xcb->last_flushed; (gdb) bt -full #0 0xf786a725 in _XSend (dpy=0x5667ec50, data=0x0, size=0) at /usr/src/debug/lib32-libx11/libX11-1.8.5/src/xcb_io.c:569 vec = {{iov_base = 0x566a0770, iov_len = 4294967295}, { iov_base = 0x0, iov_len = 4156693056}, {iov_base = 0x0, iov_len = 4154972192}} requests = dpy_request = ext = c = 0x5669b530 pad = "\000\000" dummy_request = {reqType = 0 '\000', data = 0 '\000', length = 0} #1 0xf786f902 in _XReply (dpy=0x5667ec50, rep=0xffffd370, extra=0, discard=1) at /usr/src/debug/lib32-libx11/libX11-1.8.5/src/xcb_io.c:679 error = 0x5667ec50 c = 0x5669b530 reply = current = --Type for more, q to quit, c to continue without paging-- dpy_request = __PRETTY_FUNCTION__ = "_XReply" #2 0xf78636b2 in XQueryPointer (dpy=0x5667ec50, w=20971527, root=0xffffd3f4, child=0xffffd3f8, root_x=0xffffd3fc, root_y=0xffffd400, win_x=0xffffd404, win_y=0xffffd408, mask=0xffffd40c) at /usr/src/debug/lib32-libx11/libX11-1.8.5/src/QuPntr.c:48 rep = {type = 145 '\221', sameScreen = 72 'H', sequenceNumber = 22110, length = 3558924384, root = 1449149524, child = 4294955980, rootX = 18244, rootY = 22110, winX = 336, winY = 0, mask = 61716, pad1 = 54301, pad = 3558912324} req = #3 0x565dbab0 in _glfwGetCursorPosX11 (window=0x566afdd0, xpos=0x566affa8, ypos=0x566affb0) at /home/zaafonin/Downloads/Ninecraft/glfw/src/x11_window.c:2840 root = 1449544320 child = 1 rootX = -724545232 --Type for more, q to quit, c to continue without paging-- rootY = 1848487424 childX = 1448835805 childY = 1449385972 mask = 4294956076 #4 0x565c5676 in glfwSetInputMode (handle=0x566afdd0, mode=208897, value=212994) at /home/zaafonin/Downloads/Ninecraft/glfw/src/input.c:613 window = 0x566afdd0 __PRETTY_FUNCTION__ = "glfwSetInputMode" #5 0x565b552b in main (argc=1, argv=0xffffd644) at /home/zaafonin/Downloads/Ninecraft/ninecraft/src/main.c:858 ```

which corresponds to

if (version_id >= version_id_0_6_0) {
    default_mouse_mode = GLFW_CURSOR_HIDDEN;
}

glfwSetInputMode(_window, GLFW_CURSOR, default_mouse_mode);

I've disabled the >0.6.0 check so the cursor mode is GLFW_CURSOR_NORMAL instead. That seemingly helps (also that's why 0.5.0 loads a bit further) because switching cursor mode to normal doesn't actually do anything when it's already normal, but the loading process still stops on:

``` lib: /home/zaafonin/Downloads/Ninecraft/lib/x86/libminecraftpe.so: : 0x56664a80 Ninecraft is running mcpe v0.8.1 4.6 (Compatibility Profile) Mesa 23.1.1 nine construct 0xd42dd3d0 0xffffd4c0 debug: AppPlatform_linux::readAssetFile Read asset: ./assets/images/terrain.meta debug: AppPlatform_linux::readAssetFile Read asset: ./assets/images/items.meta debug: AppPlatform_linux::isPowerVR debug: AppPlatform_linux::readAssetFile Read asset: ./assets/lang/en_US.lang debug: AppPlatform_linux::supportsTouchscreen debug: AppPlatform_linux::getPixelsPerMillimeter Thread 1 "ninecraft" received signal SIGSEGV, Segmentation fault. 0xf786a725 in _XSend (dpy=0x5667ec50, data=0x0, size=0) at /usr/src/debug/lib32-libx11/libX11-1.8.5/src/xcb_io.c:569 569 requests = dpy_request - dpy->xcb->last_flushed; (gdb) bt -full #0 0xf786a725 in _XSend (dpy=0x5667ec50, data=0x0, size=0) at /usr/src/debug/lib32-libx11/libX11-1.8.5/src/xcb_io.c:569 vec = {{iov_base = 0x566a0770, iov_len = 1457606632}, { iov_base = 0x0, iov_len = 1457606656}, { iov_base = 0xf7c23760 , iov_len = 4160736128}} requests = dpy_request = ext = c = 0x5669b530 pad = "\000\000" dummy_request = {reqType = 0 '\000', data = 0 '\000', length = 0} #1 0xf786f902 in _XReply (dpy=0x5667ec50, rep=0xffffd0f0, extra=0, discard=1) at /usr/src/debug/lib32-libx11/libX11-1.8.5/src/xcb_io.c:679 error = 0x19 c = 0x5669b530 reply = --Type for more, q to quit, c to continue without paging-- current = dpy_request = __PRETTY_FUNCTION__ = "_XReply" #2 0xf784d2cb in _XGetWindowAttributes (dpy=0x5667ec50, w=20971527, attr=0xffffd174) at /usr/src/debug/lib32-libx11/libX11-1.8.5/src/GetWAttrs.c:115 rep = {type = 49 '1', depth = 0 '\000', sequenceNumber = 0, length = 49, root = 1457158816, x = -11941, y = -2137, width = 1, height = 0, borderWidth = 60496, pad1 = 22119, pad2 = 4153934984, pad3 = 1449651280} req = i = sp = async = {next = 0x0, handler = 0xf784f100 <_XWAttrsHandler>, data = 0xffffd0dc "\250"} async_state = {attr_seq = 168, geom_seq = 169, attr = 0xffffd174} #3 0xf784d42d in XGetWindowAttributes (dpy=0x5667ec50, w=20971527, --Type for more, q to quit, c to continue without paging-- attr=0xffffd174) at /usr/src/debug/lib32-libx11/libX11-1.8.5/src/GetWAttrs.c:150 ret = #4 0x565da1db in _glfwGetWindowSizeX11 (window=0x566afe40, width=0xffffd238, height=0xffffd23c) at /home/zaafonin/Downloads/Ninecraft/glfw/src/x11_window.c:2196 attribs = {x = -11888, y = -11832, width = -139992193, height = -138266784, border_width = 45056, depth = -138269132, visual = 0xf7a7e37f <_IO_new_do_write+47>, root = 4154972047, class = 1457158816, bit_gravity = -138265280, win_gravity = -139990941, backing_store = -138265280, backing_planes = 1457158816, backing_pixel = 49, save_under = -138269132, colormap = 0, map_installed = 73, map_state = -11820, all_event_masks = -138274240, your_event_mask = 48, do_not_propagate_mask = -138269132, override_redirect = -11764, screen = 0xf7a71dbb <__GI__IO_puts+523>} --Type for more, q to quit, c to continue without paging-- #5 0x565cb632 in glfwGetWindowSize (handle=0x566afe40, width=0xffffd238, height=0xffffd23c) at /home/zaafonin/Downloads/Ninecraft/glfw/src/window.c:599 window = 0x566afe40 __PRETTY_FUNCTION__ = "glfwGetWindowSize" #6 0x5656f29d in AppPlatform_linux$getPixelsPerMillimeter ( app_platform=0xffffd4c0) at /home/zaafonin/Downloads/Ninecraft/ninecraft/src/AppPlatform_linux.c:762 ```

, so it's not GLFW that is the problem. Everything boils down to

0xf786a725 in _XSend (dpy=0x5667ec50, data=0x0, size=0)
    at /usr/src/debug/lib32-libx11/libX11-1.8.5/src/xcb_io.c:569
569             requests = dpy_request - dpy->xcb->last_flushed;     

Possible libX11 bug? Changing between native X11 and XWayland has no effect. Downgrading X11 a couple minor versions back doesn't help either.

EDIT: Downgrading lib32-libX11 to 1.7.0 pushes the loading process a bit further. Stack is corrupted, so can't provide a meaningful trace.

zaafonin commented 1 year ago

Attempted to swap the custom glfw for AUR's lib32-glfw-wayland. Surprisingly, a window actually does get initialized and loading gets quite far:

``` lib: /home/zaafonin/Downloads/Ninecraft/lib/x86/libminecraftpe.so: : 0x565f32e0 Ninecraft is running mcpe v0.8.1 4.6 (Compatibility Profile) Mesa 23.1.2 nine construct 0xd3cdd3d0 0xffffd5a0 debug: AppPlatform_linux::readAssetFile Read asset: ./assets/images/terrain.meta debug: AppPlatform_linux::readAssetFile Read asset: ./assets/images/items.meta debug: AppPlatform_linux::isPowerVR debug: AppPlatform_linux::readAssetFile Read asset: ./assets/lang/en_US.lang debug: AppPlatform_linux::supportsTouchscreen debug: AppPlatform_linux::getPixelsPerMillimeter debug: AppPlatform_linux::supportsTouchscreen debug: AppPlatform_linux::getPlatformStringVar debug: AppPlatform_linux::getPixelsPerMillimeter debug: AppPlatform_linux::getPixelsPerMillimeter debug: AppPlatform_linux::getLoginInformation [New Thread 0xd3bdeb40 (LWP 2182)] [New Thread 0xd31ffb40 (LWP 2183)] [New Thread 0xd29feb40 (LWP 2184)] [New Thread 0xd21fdb40 (LWP 2185)] debug: AppPlatform_linux::getImagePath debug: AppPlatform_linux::loadPNG debug: AppPlatform_linux::getImagePath debug: AppPlatform_linux::loadPNG debug: AppPlatform_linux::readAssetFile Read asset: ./assets/images/font/glyph_sizes.bin debug: AppPlatform_linux::updateStatsUserData debug: AppPlatform_linux::getImagePath debug: AppPlatform_linux::loadPNG debug: AppPlatform_linux::getImagePath debug: AppPlatform_linux::loadPNG debug: AppPlatform_linux::getPlatformStringVar debug: AppPlatform_linux::getPixelsPerMillimeter debug: AppPlatform_linux::getPixelsPerMillimeter debug: AppPlatform_linux::getImagePath debug: AppPlatform_linux::loadPNG debug: AppPlatform_linux::getImagePath debug: AppPlatform_linux::loadPNG debug: AppPlatform_linux::getImagePath debug: AppPlatform_linux::loadPNG debug: AppPlatform_linux::getImagePath debug: AppPlatform_linux::loadPNG debug: AppPlatform_linux::getImagePath debug: AppPlatform_linux::loadPNG debug: AppPlatform_linux::getImagePath debug: AppPlatform_linux::loadPNG debug: AppPlatform_linux::getImagePath debug: AppPlatform_linux::loadPNG debug: AppPlatform_linux::getImagePath debug: AppPlatform_linux::loadPNG Thread 1 "ninecraft" received signal SIGSEGV, Segmentation fault. 0xf7b6f311 in __glDispatchCheckMultithreaded () at ../libglvnd-v1.6.0/src/GLdispatch/GLdispatch.c:785 785 if (__glvndPthreadFuncs.equal(firstThreadId, GLVND_THREAD_NULL)) { (gdb) bt -full #0 0xf7b6f311 in __glDispatchCheckMultithreaded () at ../libglvnd-v1.6.0/src/GLdispatch/GLdispatch.c:785 tid = #1 __glDispatchCheckMultithreaded () at ../libglvnd-v1.6.0/src/GLdispatch/GLdispatch.c:766 tid = #2 0xf7aaefd2 in __eglDispatchFetchByDisplay (index=47, dpy=0x5661bc60) at ../libglvnd-v1.6.0/src/EGL/egldispatchstubs.c:66 vendor = vendor = #3 eglSwapBuffers (dpy=0x5661bc60, surface=0x56794100) at src/generate/g_egldispatchstubs.c:279 _ret = 0 _ptr_eglSwapBuffers = #4 0xf7e6f80f in ?? () from /usr/lib32/libglfw.so.3 No symbol table info available. #5 0x565b04a8 in main (argc=1, argv=0xffffd724) at /home/zaafonin/Downloads/Ninecraft/ninecraft/src/main.c:1150 st = {st_dev = 66306, __pad1 = 0, st_ino = 688134, st_mode = 16832, st_nlink = 2, st_uid = 1000, st_gid = 1000, st_rdev = 0, __pad2 = 0, st_size = 4096, st_blksize = 4096, st_blocks = 8, st_atim = {tv_sec = 1686337293, tv_nsec = 556484184}, st_mtim = { tv_sec = 1686337292, tv_nsec = 834487800}, st_ctim = {tv_sec = 1686337292, tv_nsec = 834487800}, __glibc_reserved4 = 0, __glibc_reserved5 = 0} icon = {width = 512, height = 512, pixels = 0xe63fe010 ""} in = {stlp = {buffers = {_M_end_of_storage = 0x5680a43c, _M_static_buf = "<\244\200VP=`VP=`V\370\017\000"}, _M_finish = 0x565bba00 , _M_start_of_storage = 0x565ddd42}, gnu = {data = 0x5680a43c "v%d.%d.%d alpha"}} get_game_version_string = 0x0 get_game_version_string_2 = 0xd3cdedc0 ninecraft_app_size = 3428 platform = {vtable = 0x565efc40 , handle = 0x565f32e0 , status = -1, version_id = 33, options = 0x565f2dec } minecraft_isgrabbed_offset = 3192 (gdb) ```

, line 1150 being just glfwSwapBuffers(_window); — will try to investigate more.

EDIT: Compiled bundled glfw with Wayland support and used glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_WAYLAND) in ninecraft's main.c to replicate the same effect, but with proven glfw: same segfault.

zaafonin commented 1 year ago

Commented out buffer swapping completely, and the game loads slightly further. On 0.6.1, sometimes (like 50% of times) the game crashes there:

``` Vsize: 24, 24 lib: /home/zaafonin/Downloads/Ninecraft/lib/x86/libminecraftpe.so: : 0x56676800 Ninecraft is running mcpe v0.6.1 4.6 (Compatibility Profile) Mesa 23.1.2 nine construct 0xd3e8d050 0xffffd3d0 debug: AppPlatform_linux::isPowerVR debug: AppPlatform_linux::readAssetFile Read asset: ./assets/lang/en_US.lang debug: AppPlatform_linux::isTouchscreen numBuffers: 26136 debug: AppPlatform_linux::loadTexture debug: AppPlatform_linux::getOptionsStrings debug: AppPlatform_linux::isTouchscreen debug: AppPlatform_linux::getPlatformStringVar debug: AppPlatform_linux::getPixelsPerMillimeter debug: AppPlatform_linux::getPixelsPerMillimeter debug: AppPlatform_linux::loadTexture debug: AppPlatform_linux::getPlatformStringVar debug: AppPlatform_linux::getPixelsPerMillimeter debug: AppPlatform_linux::getPixelsPerMillimeter Thread 1 "ninecraft" received signal SIGSEGV, Segmentation fault. 0xe128c252 in stpcpy (__src=, __dest=, __dest=, __src=) at /usr/include/bits/string_fortified.h:86 86 return __builtin___stpcpy_chk (__dest, __src, __glibc_objsize (__dest)); (gdb) bt -full #0 0xe128c252 in stpcpy (__src=, __dest=, __dest=, __src=) at /usr/include/bits/string_fortified.h:86 No locals. #1 sd_machine_get_class (machine=0xffffcdf0 "borobox", class=0xffffcb68) at ../systemd-stable/src/libsystemd/sd-login/sd-login.c:1076 _appendees_ = _len_ = _i_ = 1 _d_ = 0xffffca90 "/run/systemd/machines/\377\377\370\214,\341h\313\377\377\320\301", _p_ = 0xffffcaa6 "\377\377\370\214,\341h\313\377\377\320\301", c = p = r = __func__ = "sd_machine_get_class" _pvar_ = _var_ = _nullvalue_ = #2 0xe1281a67 in _nss_mymachines_gethostbyname3_r (name=0xffffcdf0 "borobox", af=, result=0xf7c279c0 , buffer=0x56b82b00 "", buflen=1024, errnop=0xf7c36c14, h_errnop=0xffffcdac, ttlp=0x0, canonp=0x0) at ../systemd-stable/src/nss-mymachines/nss-mymachines.c:274 --Type for more, q to quit, c to continue without paging-- reply = 0x0 bus = 0x0 class = 0x0 c = 0 i = 0 r_name = r_aliases = r_addr = r_addr_list = l = idx = ms = alen = r = _saved_errno_ = 2 _saved_sigset = {__val = {0 }} __func__ = "_nss_mymachines_gethostbyname3_r" --Type for more, q to quit, c to continue without paging-- #3 0xe1282251 in _nss_mymachines_gethostbyname_r (name=0xffffcdf0 "borobox", host=0xf7c279c0 , buffer=0x56b82b00 "", buflen=1024, errnop=0xf7c36c14, h_errnop=0xffffcdac) at ../systemd-stable/src/nss-mymachines/nss-mymachines.c:404 ret = #4 0xf7b383cd in __gethostbyname_r (name=, resbuf=, buffer=, buflen=, result=, h_errnop=) at ../nss/getXXbyYY_r.c:273 nip = 0x56754c68 do_merge = 0 mergegrp = mergebuf = 0x0 endptr = 0x0 fct = {l = 0xe12821e0 <_nss_mymachines_gethostbyname_r>, ptr = 0xe12821e0 <_nss_mymachines_gethostbyname_r>} no_more = 0 err = status = NSS_STATUS_UNAVAIL nscd_status = any_service = true res_ctx = res = #5 0xf7b378f7 in gethostbyname (name=0xffffcdf0 "borobox") at ../nss/getXXbyYY.c:139 --Type for more, q to quit, c to continue without paging-- buffer_size = 1024 resbuf = {h_name = 0x0, h_aliases = 0x0, h_addrtype = 0, h_length = 0, h_addr_list = 0x0} result = 0x0 h_errno_tmp = 0 res_ctx = 0x56b820a0 #6 0xd404d946 in ?? () No symbol table info available. Backtrace stopped: previous frame inner to this frame (corrupt stack?) ```

No such behavior on 0.8.1. Now I certainly would be happy if the game worked with rendering enabled...

EDIT: This happened because lib32-systemd was installed which leads to to the gethostbyname segfault. This was only the case on 0.6.1 because this function is called almost immediately on start. On 0.8.1 it does happen, just later.

MFDGaming commented 1 year ago

You most likely don't have a 32bit video driver

zaafonin commented 1 year ago

Not the case. 32-bit Wine stuff wouldn't work either then.

zaafonin commented 1 year ago

Further observations. 1) The X11 segfault can be fixed by downgrading lib32-libx11 to 1.6.8 (gosh that's ancient)

2) Segfaulting in libglvnd:

Thread 1 "ninecraft" received signal SIGSEGV, Segmentation fault.
0xf799c311 in __glDispatchCheckMultithreaded () at ../libglvnd-v1.6.0/src/GLdispatch/GLdispatch.c:785
785                 if (__glvndPthreadFuncs.equal(firstThreadId, GLVND_THREAD_NULL)) {  

can be fixed by compiling the master branch of libglvnd for x86 and LD_PRELOADing libGLdispatch.so. Probably will be the only solution until the fix lands into the 2023 release. After this, you will finally get to the main menu: image You will be able to navigate the menu freely, create a world, but half a second later you will be met with another segfault.

3) Next problem you'll encounter is a mystery segfault somewhere deep in amd drivers:

Thread 1 "ninecraft" received signal SIGSEGV, Segmentation fault.
0xf6d23620 in amdgpu_bo_va_op (bo=0x568ebb40, offset=0, size=2097152, addr=4303355904, flags=0, ops=2)
    at ../libdrm-2.4.115/amdgpu/amdgpu_bo.c:754
Downloading source file /usr/src/debug/lib32-libdrm/build/../libdrm-2.4.115/amdgpu/amdgpu_bo.c
754     ../libdrm-2.4.115/amdgpu/amdgpu_bo.c: Directory not empty.           

(can also be "Bad file descriptor" or something else). Sometimes you will be able to avoid the segfault altogether (or rather skip to the next segfault), either by pure luck or by doing run in gdb after the segfault has happened, which restarts ninecraft. Again, I have no idea how or why this happens. This might be an AMD-exclusive problem.

Surprisingly, this problem disappears if you switch to Zink (can be done with MESA_LOADER_DRIVER_OVERRIDE=zink). However, on AMD you'll need to install lib32-amdvlk instead of lib32-vulkan-radeon. The importance of this will be explained further.

4) Next segfault happens in libXi, possibly because it isn't downgraded together with libx11:

Thread 1 "ninecraft" received signal SIGSEGV, Segmentation fault.
0xf77821f4 in XInputWireToCookie (dpy=0x56690c30, cookie=0x569962d4, event=0x56f5a5f0)
    at /usr/src/debug/lib32-libxi/libXi-1.8.1/src/XExtInt.c:1007
1007                *cookie = *(XGenericEventCookie*)save;      

Unfortunately, Arch doesn't have libXi 1.6.8 in its repos anymore, so the downgrade isn't really possible. I took a radical approach and switched to Wayland (no matter how I dislike this thing). Despite GLFW_BUILD_WAYLAND already being used in the code, I couldn't force ninecraft to use it (even with glfwWindowHint(GLFW_PLATFORM, GLFW_PLATFORM_WAYLAND); for some reason).

What helped is screwing with CMakeLists.txt of the bundled glfw, specifically with lines 40 and 41:

cmake_dependent_option(GLFW_BUILD_X11 "Build support for X11" OFF "UNIX;NOT APPLE" OFF)
cmake_dependent_option(GLFW_BUILD_WAYLAND "Build support for Wayland" ON "UNIX;NOT APPLE" OFF)

This is 100% bad code, but it does the job of forcing glfw (and ninecraft) to use Wayland. Finally the binary starts, the world loads and the game works. image

P.S. On importance of lib32-amdvlk and other 32-bit libs:

For Zink, it would be logical to use lib32-vulkan-radeon as it's pretty much the default choice for Vulkan drivers on AMD. However, this package depends on lib32-systemd among other stuff, and while I'm not a systemd hater by all means, mcpe on ninecraft surely is:

Thread 1 "ninecraft" received signal SIGSEGV, Segmentation fault.
0xd011e252 in stpcpy (__src=<optimized out>, __dest=<optimized out>, __dest=<optimized out>, __src=<optimized out>)
    at /usr/include/bits/string_fortified.h:86
86        return __builtin___stpcpy_chk (__dest, __src, __glibc_objsize (__dest));

Backtrace shows the culprit is libsystemd:

``` (gdb) bt #0 0xd011e252 in stpcpy (__src=, __dest=, __dest=, __src=) at /usr/include/bits/string_fortified.h:86 #1 sd_machine_get_class (machine=0xffffce80 "borobox", class=0xffffcbf8) at ../systemd-stable/src/libsystemd/sd-login/sd-login.c:1076 #2 0xd0113a67 in _nss_mymachines_gethostbyname3_r (name=0xffffce80 "borobox", af=, result=0xf7a279c0 , buffer=0x57726010 "", buflen=1024, errnop=0xf7a3d190, h_errnop=0xffffce3c, ttlp=0x0, canonp=0x0) at ../systemd-stable/src/nss-mymachines/nss-mymachines.c:274 #3 0xd0114251 in _nss_mymachines_gethostbyname_r (name=0xffffce80 "borobox", host=0xf7a279c0 , buffer=0x57726010 "", buflen=1024, errnop=0xf7a3d190, h_errnop=0xffffce3c) at ../systemd-stable/src/nss-mymachines/nss-mymachines.c:404 #4 0xf79383cd in __gethostbyname_r (name=, resbuf=, buffer=, buflen=, result=, h_errnop=) at ../nss/getXXbyYY_r.c:273 --Type for more, q to quit, c to continue without paging-- #5 0xf79378f7 in gethostbyname (name=0xffffce80 "borobox") at ../nss/getXXbyYY.c:139 #6 0xd7f8aa97 in ?? () Backtrace stopped: previous frame inner to this frame (corrupt stack?) ```

It looks like if lib32-systemd is installed, gethostbyname happens via libsystemd, where the segfault happens most probably because of a yet another ABI incompatibility. The only solution I've found is not having lib32-systemd in your system. lib32-amdvlk doesn't have it as a dependency, and that's why it's the best solution unless either the systemd dependency is circumvented or the underlying bug is fixed.

This problem is also present with lib32-pipewire and lib32-libpulse. For now I haven't found a way to use ninecraft with sound.

In conclusion, this problem looks like a whole can of worms resulting from the nonexistent culture of ABI compatibility in Linux systems. While the described manipulations worked on my machine, this might not be possible on systems without Vulkan, or Wayland or other stuff I don't know about. TL;DR: desktop Linux sucks

kran27 commented 8 months ago

any chance you could provide your build? I tried getting it to compile following these instructions on my steam deck but ran into additional issues with linux headers and other stuff that I couldn't figure out.

Lassebq commented 2 weeks ago

Hey guys, new crash just dropped:

#0  0x565bd2e6 in stbi.compute_huffman_codes ()
#1  0x565bdd55 in stbi.parse_zlib ()
#2  0x565c2678 in stbi.parse_png_file ()
#3  0x565cd048 in stbi.load_main ()
#4  0x565d0be4 in stbi.load_and_postprocess_8bit ()
#5  0x565d16ee in stbi_load ()
#6  0x56575637 in AppPlatform_linux$loadTexture ()
#7  0xde4f895f in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Happens on first loadTexture call with assets/particles.png

Lassebq commented 2 weeks ago

Forget it, I guess I was building incorrectly. Still not sure what to do with libnss_resolve.so incompatibility with gethostbyname. I tried building a minimal 32 bit executable which calls it but it works there.

$ cat test.c 
#include <netdb.h>
#include <stdio.h>

int main(int argc, char **argv) {
    printf("%s", gethostbyname("arch")->h_name);
    return 0;
}
$ gcc -m32 test.c
$ ./a.out                                                       
arch

When it's called by mcpe it always segfaults. I even tried wrapping it in net_hooks[]: {"gethostbyname", my_gethostbyname}

struct hostent * my_gethostbyname(const char *name) {
    return gethostbyname(name);
}

The only workaround I found is to return NULL in the above function.