Skip to content

/server <stop/restart> command#3219

Open
tillpp wants to merge 62 commits into
PixelGuys:masterfrom
tillpp:stop
Open

/server <stop/restart> command#3219
tillpp wants to merge 62 commits into
PixelGuys:masterfrom
tillpp:stop

Conversation

@tillpp

@tillpp tillpp commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

stops the server
restarts the server

TODO list:

  • /server stop with head
  • /server stop with head and then rejoining a world
  • /server restart work on headfull server
  • /server stop on headless (with a client connected)
  • /server restart on headless (with a client connected)

btw. restart and reload are not the same. restart does kick all players except the host, reload doesn't kick any player

@tillpp tillpp marked this pull request as draft June 12, 2026 22:41
@tillpp tillpp requested a review from Wunka June 12, 2026 22:56
@tillpp

tillpp commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

i have to say, that i am very unfamiliar with this part of the codebase.(anything with items)
So expect this PR to be bad. I am not sure either what i am doing.

main.threadPool.clear(); // <-- this prevents
//  leaked user, but should i really be doing this here?

main.items.clearRecipeCachedInventories(); // <-- this removed
// a memory Leak, but should i really be doing this here?

if you got better idea, improvements, feel free to review & comment
Good night

Comment thread src/items.zig Outdated

@Wunka Wunka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Command code looks good. I don't know the rest of code so I cannot good review it.
But as restart doesn't work for me my requested change is to make it work

@tillpp

tillpp commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

But as restart doesn't work for me my requested change is to make it work

when i did request a review from you, restart wasn't there yet. It also isn't finished yet.
I am more interested in the

main.threadPool.clear();
main.items.clearRecipeCachedInventories();

  1. I know that you too struggled with "Leaked Player", right?
    Might the missing main.threadPool.clear() be the same cause for your problem?

2.main.threadPool.clear(); does also clear the tasks from the client. Is that a problem?
or is there a way to clear only the task of the server?

those questions are not only towards you, but also everyone else reviewing this PR

@Wunka

Wunka commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

those questions are not only towards you, but also everyone else reviewing this PR

Those questions can be answered but other people because I have no idea. I have never touched those parts of the codebase (yes I did something with recipes but not that part. It seems #1824 did that).And the pr that fixed the leaked player issue was this: #3019

@IntegratedQuantum

Copy link
Copy Markdown
Member

I find both of these odd. These are a sign that the server is not cleaned up properly in deinit (see #2293), I'd suggest to address #2293 first, then you should be able to just do deinit here as normally.

clearRecipeCachedInventories

This function looks completely broken, it frees entries with the wrong allocator, I'll investigate this, but I think we can just remove it entirely.

@tillpp tillpp marked this pull request as ready for review June 13, 2026 20:12
@tillpp tillpp changed the title /stop command /server <stop/restart> command Jun 13, 2026
@tillpp

tillpp commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

ready for review now.
I am not exactly sure what I am doing myself, reordering the deinit/inits
but it makes the crashes go away.

Comment thread src/server/command/server.zig Outdated
Comment thread src/block_entity.zig Outdated
Comment thread src/items.zig Outdated
@Wunka Wunka moved this to Easy to Review in PRs to review Jun 13, 2026
Comment thread src/main.zig
Comment thread src/utils.zig
Comment thread src/network.zig Outdated
Comment thread src/server/server.zig Outdated
Comment thread src/server/server.zig Outdated
Comment thread src/network.zig Outdated
Comment thread src/network.zig

@IntegratedQuantum IntegratedQuantum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it crashes sporadically when I do /server stop in headfull

thread 60237 panic: index out of bounds: index 0, len 0
/home/mint/Downloads/tillpp/src/blocks.zig:700:44: 0x16c7822 in fogDensity (main.zig)
  return textureFogData.items[animationData[textureIndices[block.typ][0]].startFrame].fogDensity;
                                           ^
/home/mint/Downloads/tillpp/src/renderer.zig:462:32: 0x16c6d1e in render (main.zig)
  extractImageDataAndDownsample(playerBlock, playerPos, viewMatrix);
                               ^
/home/mint/Downloads/tillpp/src/renderer.zig:296:15: 0x16b61d3 in renderWorld (main.zig)
  Bloom.render(lastWidth, lastHeight, playerBlock, playerPos, game.camera.viewMatrix);
              ^
/home/mint/Downloads/tillpp/src/renderer.zig:161:13: 0x16b40b6 in render (main.zig)
 renderWorld(game.world.?, ambient, game.fog.skyColor, playerPosition);
            ^
/home/mint/Downloads/tillpp/src/main.zig:620:20: 0x1771b6c in clientMain (main.zig)
    renderer.render(game.Player.getEyePosBlocking(), deltaTime);
                   ^
/home/mint/Downloads/tillpp/src/main.zig:531:13: 0x15b11a6 in main (main.zig)
  clientMain();
            ^
/home/mint/Cubyz/compiler/zig/lib/std/start.zig:699:88: 0x15b08ae in callMain (std.zig)
    if (fn_info.params[0].type.? == std.process.Init.Minimal) return wrapMain(root.main(.{
                                                                                       ^
../sysdeps/nptl/libc_start_call_main.h:58:16: 0x78df6fe29d8f in __libc_start_call_main (../sysdeps/x86/libc-start.c)
../csu/libc-start.c:392:3: 0x78df6fe29e3f in __libc_start_main_impl (../sysdeps/x86/libc-start.c)
???:?:?: 0x1e2c004 in ??? (???)

@tillpp

tillpp commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

wait found a bug in headless, don't merge

@tillpp

tillpp commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

done and tested !

@IntegratedQuantum

Copy link
Copy Markdown
Member

still crashes (43690 is undefined by the way)

thread 22734 panic: index out of bounds: index 43690, len 4080
/home/mint/Downloads/tillpp/src/models.zig:89:22: 0x16d847b in quadInfo (main.zig)
  return &quads.items[@intFromEnum(self)];
                     ^
/home/mint/Downloads/tillpp/src/models.zig:625:34: 0x1cd7c22 in getRawFaces (main.zig)
    var quad = quadIndex.quadInfo().*;
                                 ^
/home/mint/Downloads/tillpp/src/rotation.zig:68:25: 0x1cd9950 in rayModelIntersection (main.zig)
   modelData.getRawFaces(&quadList);
                        ^
/home/mint/Downloads/tillpp/src/rotation.zig:60:31: 0x1cd96bf in rayIntersection (main.zig)
   return rayModelIntersection(blocks.meshes.model(block), relativePlayerPos, playerDir);
                              ^
/home/mint/Downloads/tillpp/mods/cubyz/rotations/stairs.zig:318:54: 0x1cf478f in rayIntersection (rotations.zig)
 return RotationMode.DefaultFunctions.rayIntersection(block, item, relativePlayerPos, playerDir);
                                                     ^
/home/mint/Downloads/tillpp/src/renderer.zig:949:37: 0x16fbfeb in select (main.zig)
    if (block.mode().rayIntersection(block, item, relativePlayerPos, _dir)) |intersection| {
                                    ^
/home/mint/Downloads/tillpp/src/renderer.zig:229:22: 0x16b5588 in renderWorld (main.zig)
 MeshSelection.select(playerPos, direction, game.Player.inventory.getItem(game.Player.selectedSlot));
                     ^
/home/mint/Downloads/tillpp/src/renderer.zig:161:13: 0x16b40b6 in render (main.zig)
 renderWorld(game.world.?, ambient, game.fog.skyColor, playerPosition);
            ^
/home/mint/Downloads/tillpp/src/main.zig:626:20: 0x1771b6c in clientMain (main.zig)
    renderer.render(game.Player.getEyePosBlocking(), deltaTime);
                   ^
/home/mint/Downloads/tillpp/src/main.zig:531:13: 0x15b11a6 in main (main.zig)
  clientMain();
            ^
/home/mint/Cubyz/compiler/zig/lib/std/start.zig:699:88: 0x15b08ae in callMain (std.zig)
    if (fn_info.params[0].type.? == std.process.Init.Minimal) return wrapMain(root.main(.{
                                                                                       ^

How about only unloading the assets in headless mode, and giving that responsibility to the client in headfull?

@tillpp

tillpp commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

does it crash in stop or restart or both.
please be more descriptive in the future when posting a crash

(right, i remember, we removed restart in headfull )

@tillpp

tillpp commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

can you try again? It should work now
if it doesn't we can try this next:

How about only unloading the assets in headless mode, and giving that responsibility to the client in headfull?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants