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

Crash on startup (Segmentation fault) on OpenWRT mips #5537

Open
loss-and-quick opened this issue Oct 24, 2023 · 10 comments
Open

Crash on startup (Segmentation fault) on OpenWRT mips #5537

loss-and-quick opened this issue Oct 24, 2023 · 10 comments
Labels

Comments

@loss-and-quick
Copy link

loss-and-quick commented Oct 24, 2023

Client version: unkown
Server OS: OpenWRT
Cuberite Commit id: ca705be

Expected behavior

Didn't crash on startup

Actual behavior

It crashes on startup

Steps to reproduce the behavior

Compile this project using OpenWRT SDK for ramips/mt7621 with cmake ... -DNO_NATIVE_OPTIMIZATION=YES ..

Server log

[b1072b10|16:22:56] --- Started Log ---
[b1072b10|16:22:56] Cuberite local build (id: Unknown)
[b1072b10|16:22:56] from commit approx: ca705be2649a205caac2a449704b55dd029ea13b built at: approx: 2023-10-18 23:32:02 +0300
[b1072b10|16:22:56] Creating new server instance...
[b1072b10|16:22:56] Reading server config...
[b1072b10|16:22:56] Regenerating settings.ini, all settings will be reset
[b1072b10|16:22:56] Starting server...
[b1072b10|16:22:56] Compatible clients: 1.8.x-1.14.4
[b1072b10|16:22:56] Compatible protocol versions 47, 107, 108, 109, 110, 210, 315, 316, 335, 338, 340, 393, 401, 477, 480, 485, 490, 498
[b1072b10|16:22:57] Generating protocol encryption keypair...
[b1072b10|16:22:57] Regenerating webadmin.ini, all settings will be reset
[b1072b10|16:22:57] Initialising WebAdmin...
[b1072b10|16:22:57] The webadmin is enabled but has no users configured. To add new users, edit webadmin.ini
[b1072b10|16:22:57] WebServer: The server will run in unsecured HTTP mode.
[b1072b10|16:22:57] Put a valid HTTPS certificate in file 'webadmin/httpscert.crt' and its corresponding private key to 'webadmin/httpskey.pem' (without any password) to enable HTTPS support
[b1072b10|16:22:57] Loading settings...
[b1072b10|16:22:58] Creating default ranks...
[b1072b10|16:22:58] Default ranks created.
[b1072b10|16:22:58] Loading crafting recipes from crafting.txt...
[b1072b10|16:22:59] Loaded 789 crafting recipes
[b1072b10|16:22:59] Loaded 1.12.2 380 recipe book
[b1072b10|16:22:59] Cannot open file "Protocol/1.13/base.recipes.txt", no recipe book recipes will be available!
[b1072b10|16:22:59] Cannot open file "Protocol/1.14.4/base.recipes.txt", no recipe book recipes will be available!
[b1072b10|16:22:59] Loading furnace recipes...
[b1072b10|16:22:59] Loaded 67 furnace recipes and 66 fuels
[b1072b10|16:22:59] Loading brewing recipes...
[b1072b10|16:22:59] Loaded 49 brewing recipes
[b1072b10|16:22:59] Loading worlds...
[b1072b10|16:22:59] cWorld::cWorld("world")
[b1072b10|16:22:59] Failed to load scoreboard from "world/data/scoreboard.dat": basic_ios::clear: iostream error
[b1072b10|16:22:59] Cannot read world settings from "world/world.ini", defaults will be used.
[b1072b10|16:22:59] Allowed mob: bat
[b1072b10|16:22:59] Allowed mob: cavespider
[b1072b10|16:22:59] Allowed mob: chicken
[b1072b10|16:22:59] Allowed mob: cow
[b1072b10|16:22:59] Allowed mob: creeper
[b1072b10|16:22:59] Allowed mob: guardian
[b1072b10|16:22:59] Allowed mob: horse
[b1072b10|16:22:59] Allowed mob: mooshroom
[b1072b10|16:22:59] Allowed mob: ocelot
[b1072b10|16:22:59] Allowed mob: pig
[b1072b10|16:22:59] Allowed mob: rabbit
[b1072b10|16:22:59] Allowed mob: sheep
[b1072b10|16:22:59] Allowed mob: silverfish
[b1072b10|16:22:59] Allowed mob: skeleton
[b1072b10|16:22:59] Allowed mob: slime
[b1072b10|16:22:59] Allowed mob: spider
[b1072b10|16:22:59] Allowed mob: squid
[b1072b10|16:22:59] Allowed mob: wolf
[b1072b10|16:22:59] Allowed mob: zombie
[b1072b10|16:22:59] Chosen a new random seed for world: 1335985483
[b1072b10|16:22:59] Using a cache for biomegen of size 16.
[b1072b10|16:22:59] Enabling multicache for biomegen of length 128.
[b1072b10|16:23:00] Invalid biome ("BambooJungle") specified in AllowedBiomes in cubeset file Prefabs/SinglePieceStructures/JungleTemple.cubeset. Skipping the biome.
[b1072b10|16:23:00] Invalid biome ("BambooJungleHills") specified in AllowedBiomes in cubeset file Prefabs/SinglePieceStructures/JungleTemple.cubeset. Skipping the biome.
[b1072b10|16:23:01] cWorld::cWorld("world_nether")
[b1072b10|16:23:01] Failed to load scoreboard from "world_nether/data/scoreboard.dat": basic_ios::clear: iostream error
[b1072b10|16:23:01] Cannot read world settings from "world_nether/world.ini", defaults will be used.
[b1072b10|16:23:01] Allowed mob: blaze
[b1072b10|16:23:01] Allowed mob: ghast
[b1072b10|16:23:01] Allowed mob: magmacube
[b1072b10|16:23:01] Allowed mob: witherskeleton
[b1072b10|16:23:01] Allowed mob: zombiepigman
[b1072b10|16:23:01] Chosen a new random seed for world: 717257826
[b1072b10|16:23:01] cWorld::cWorld("world_the_end")
[b1072b10|16:23:01] Failed to load scoreboard from "world_the_end/data/scoreboard.dat": basic_ios::clear: iostream error
[b1072b10|16:23:01] Cannot read world settings from "world_the_end/world.ini", defaults will be used.
[b1072b10|16:23:01] Chosen a new random seed for world: 1637737994
[b1072b10|16:23:02] Loading plugin manager...
[b1072b10|16:23:02] -- Loading Plugins --
[b1072b10|16:23:03] [Core] Initialised!
[b1072b10|16:23:03] [ChatLog] Initialized ChatLog v.3
[b1072b10|16:23:03] -- Loaded 2 Plugins --
[b1072b10|16:23:03] Loading MonsterConfig...
[b1072b10|16:23:03] Starting Authenticator...
[b1072b10|16:23:03] Starting worlds...
[b1072b10|16:23:03] Generating random spawnpoint...
Segmentation fault
@bearbin
Copy link
Member

bearbin commented Oct 24, 2023

Interesting idea to compile Cuberite for an OpenWRT platform, I guess routers do actually have enough power to run Minecraft now!

Sadly I think this might need some debugging, and I don't think any of the devs would be able to reproduce on our own hardware.

Would you be able to please run this inside GDB and provide the logs of where the segfault occurred, or provide a core dump for us to take a look at?

@bearbin bearbin added the crash label Oct 24, 2023
@loss-and-quick
Copy link
Author

loss-and-quick commented Oct 24, 2023

Would you be able to please run this inside GDB and provide the logs of where the segfault occurred, or provide a core dump for us to take a look at?

How i can do it on OpenWRT?

UPD: @bearbin , I found this guide, but what should I do in the gdb console?

@loss-and-quick
Copy link
Author

Sadly I think this might need some debugging, and I don't think any of the devs would be able to reproduce on our own hardware.

Isn't it possible to run mips architecture through Qemu?

@bearbin
Copy link
Member

bearbin commented Oct 24, 2023

Would you be able to please run this inside GDB and provide the logs of where the segfault occurred, or provide a core dump for us to take a look at?

How i can do it on OpenWRT?

UPD: @bearbin , I found this guide, but what should I do in the gdb console?

You should just be able to use the run command, which will start cuberite, and when it crashes it should give you a stacktrace (I think you're compiling in debug mode so debug symbols are turned on).

Sadly I think this might need some debugging, and I don't think any of the devs would be able to reproduce on our own hardware.

Isn't it possible to run mips architecture through Qemu?

Possibly, although there's no guarantee that the same error would result as on your hardware. So it's easier to confirm on the real hardware first rather than try and set up a whole emulated VM.

@loss-and-quick
Copy link
Author

loss-and-quick commented Oct 24, 2023

You should just be able to use the run command, which will start cuberite, and when it crashes it should give you a stacktrace (I think you're compiling in debug mode so debug symbols are turned on).

Reading /usr/lib/libstdc++.so.6 from remote target...
Reading /lib/libgcc_s.so.1 from remote target...
[New Thread 10757.10764]
[New Thread 10757.10758]
[New Thread 10757.10759]
[New Thread 10757.10760]
[New Thread 10757.10761]
[New Thread 10757.10762]
[New Thread 10757.10763]
[New Thread 10757.10765]
[New Thread 10757.10766]

Thread 2 "Cuberite" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 10757.10764]
0x008887ac in cChunkDesc::GetChunkX (this=0x0) at /builder/cuberite/src/Generating/ChunkDesc.h:49
49		int GetChunkX() const { return m_Coords.m_ChunkX; }  // Prefer GetChunkCoords() instead

Also i checked dmesg:

[42964.454304] do_page_fault(): sending SIGSEGV to Cuberite for invalid write access to 73d3bfec
[42964.462908] epc = 00b907b4 in Cuberite[400000+10a4000]
[42964.468127] ra  = 00b6aab0 in Cuberite[400000+10a4000]

I guess that at the moment of world creation there is a spike in ram consumption, and since I have ~30MB + 1GB swap free, this is the reason, although usually if some process uses all the ram, the router just hangs intentionally( But Tor works fine, although it consumed about 160 mb ram )

@loss-and-quick loss-and-quick changed the title Crash on startup (Segmentation fault) Crash on startup (Segmentation fault) on OpenWRT mips Oct 24, 2023
@loss-and-quick
Copy link
Author

@bearbin , did you checked this

@loss-and-quick
Copy link
Author

loss-and-quick commented Mar 18, 2024

Using the last commit ( 5fd7cc3 ) the problem is still there

UDP:
If I run the server on a regular linux x64, and move the generated worlds to the server folder on the router, then there is another cause of the error:

Thread 2 "Cuberite" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 8916.8922]
0x00b908e4 in Compression::Extractor::Extract<&libdeflate_zlib_decompress> (this=0x0, Input=...) at /builder/cuberite/src/StringCompression.cpp:188
188	Compression::Result Compression::Extractor::Extract(const ContiguousByteBufferView Input)

Maybe ram is not enough?

@madmaxoft
Copy link
Member

I'm wondering, what C/C++ runtime library does OpenWRT use? Cuberite has had some problems with some alternate libraries, such as musl, due to stack size. Cuberite requires a rather huge stack (on the order of megabytes) for its world generators, which I believe could be a showstopper for running on these low-RAM systems. Still, it's a segfault, not a stack error, so hard to say.

@loss-and-quick
Copy link
Author

loss-and-quick commented Sep 9, 2024

I'm wondering, what C/C++ runtime library does OpenWRT use? Cuberite has had some problems with some alternate libraries, such as musl, due to stack size

I use gcc to complie, but as i know openWRT use musl runtime as well

Cuberite requires a rather huge stack (on the order of megabytes) for its world generators, which I believe could be a showstopper for running on these low-RAM systems.

I figured it, but i also tried to generate world on pc and copy it to router, but there is a another error accured

@madmaxoft
Copy link
Member

That's probably it, then. The generator is the most hungry, but it's not the only thing. The zlib compression (used everywhere in Minecraft) also uses statically-sized stack-based buffers, so that's probably the cause for the other error.
I seem to remember we wanted to fix at least the compression code, I thought it was already fixed, but maybe it's not. Sorry, I've been away from the project for quite some time, can't tell more, the knowledge has been swapped out of my head.

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

No branches or pull requests

3 participants