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

GameTest Simulated Players Causes Server Crash #51

Closed
PrimeStrat opened this issue Sep 14, 2024 · 2 comments
Closed

GameTest Simulated Players Causes Server Crash #51

PrimeStrat opened this issue Sep 14, 2024 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@PrimeStrat
Copy link

PrimeStrat commented Sep 14, 2024

Describe the bug
Spawning a simulated player via Scripting API's GameTest function causes a crash.

To Reproduce
Script used to spawn simulated players:

import * as Minecraft from "@minecraft/server";
import * as GameTest from "@minecraft/server-gametest";

export class SimulationManager {
    static _tickEvent() {
        const result = this._jobs.keys().next();
        if (this._test === null)
            return;
        if (result.done)
            return;
        const name = this._jobs.get(result.value);
        this._results.set(result.value, this._test.spawnSimulatedPlayer({ x: 0, y: 0, z: 0 }, name));
        this._jobs.delete(result.value);
    }
    static spawnSimulatedPlayer(name, location) {
        const jobID = this._jobID++;
        this._jobs.set(jobID, name);
        return new Promise(resolve => {
            const intervalID = Minecraft.system.runInterval(() => {
                if (!this._results.has(jobID))
                    return;
                const simulatedPlayer = this._results.get(jobID);
                this._results.delete(jobID);
                Minecraft.system.clearRun(intervalID);
                simulatedPlayer.teleport(location);
                resolve(simulatedPlayer);
            }, 1);
        });
    }
    static initiate() {
        const registration = GameTest.register("simulation_manager", "spawn_simulated_player", test => this._test = test);
        registration.maxTicks(0x7FFFFFFF);
        registration.structureName("simulation_manager:empty");
        registration.tag(GameTest.Tags.suiteDefault);
        Minecraft.system.runInterval(() => this._tickEvent(), 4);
        Minecraft.world.getDimension("nether").runCommand("gametest run simulation_manager:spawn_simulated_player");
    }
    constructor() { }
    ;
}

SimulationManager._jobID = 0;
SimulationManager._test = null;
SimulationManager._jobs = new Map();
SimulationManager._results = new Map();

Then you do:

SimulationManager.initiate()
await sim.SimulationManager.spawnSimulatedPlayer(`§8[§7Test Bot§8] Bootswiththefurr${i}`, {x: 0, y: 0, z: 0})

Error Log:

[2024-09-14 11:56:34.246 INFO] [Server] Player Spawned: [Test Bot] Bootswiththefurr0 xuid: , pfid:
=== ENDSTONE CRASHED! - PLEASE REPORT THIS AS AN ISSUE ON GITHUB ===
Operation system: Windows
Endstone version: 0.5.3
Api version     : 0.5
Description     : Signal received: 22
Stack trace (most recent call first):
#0  0x7ff9d4d2c1fe     (0x1800cc1fe) in endstone::detail::`anonymous namespace'::signal_handler(int) at D:\a\endstone\endstone\src\endstone_runtime\windows\signal_handler.cpp:47
#1  0x7ffa7c19e6d4     (0x18007e6d4) in raise
#2  0x7ffa7c19f6e0     (0x18007f6e0) in abort
#3  0x7ffa7c19ee18     (0x18007ee18) in terminate
#4  0x7ffa67f41ab0     (0x180001ab0) in __NLG_Return2
#5  0x7ffa67f4232e     (0x18000232e) in __NLG_Return2
#6  0x7ffa67f42388     (0x180002388) in __NLG_Return2
#7  0x7ffa67f44188     (0x180004188) in __CxxFrameHandler4
#8  0x7ffa7ee751de     (0x1800a51de) in __chkstk
#9  0x7ffa7edee865     (0x18001e865) in RtlFindCharInUnicodeString
#10 0x7ffa7ee24944     (0x180054944) in RtlRaiseException
#11 0x7ffa7c51fabb     (0x18005fabb) in RaiseException
#12 0x7ffa67f427b2     (0x1800027b2) in __NLG_Return2
#13 0x7ffa7ee74a25     (0x1800a4a25) in RtlCaptureContext2
#14 0x7ff9d4cb571f     (0x18005571f) in entt::basic_storage<endstone::detail::EndstonePlayer, EntityId, std::allocator<endstone::detail::EndstonePlayer>, void>::emplace_element<endstone::detail::EndstoneServer &, Player &>(entt::basic_storage<endstone::detail::EndstonePlayer, EntityId, std::allocator<endstone::detail::EndstonePlayer>, void>*, EntityId, EntityId, bool) at C:\Users\runneradmin\AppData\Local\Temp\tmpredpg8ya\build\_deps\entt-src\src\entt\entity\storage.hpp:269
#15 0x7ff9d4cb6a7b     (0x180056a7b) in entt::basic_registry<EntityId, std::allocator<EntityId> >::get_or_emplace<endstone::detail::EndstonePlayer, endstone::detail::EndstoneServer &, Player &>(EntityId, endstone::detail::EndstoneServer&, Player&) at C:\Users\runneradmin\AppData\Local\Temp\tmpredpg8ya\build\_deps\entt-src\src\entt\entity\registry.hpp:904
#16 0x7ff9d4cc8c79     (0x180068c79) in Player::teleportTo(Vec3&, bool, int, int, int) at D:\a\endstone\endstone\src\endstone_runtime\bedrock\world\actor\player\player.cpp:34
#17 0x7ff624c32567     (0x141722567) in  ??
#18 0x7ff9d4cac2d5     (0x18004c2d5) in TeleportCommand::applyTarget(TeleportTarget*, TeleportTarget*) at D:\a\endstone\endstone\src\endstone_runtime\bedrock\server\commands\standard\teleport_command.cpp:30
#19 0x7ff624b16e14     (0x141606e14) in  ??
#20 0x7ff624b9221d     (0x14168221d) in  ??
#21 0x7ff624a8dbde     (0x14157dbde) in  ??
#22 0x7ff624b49209     (0x141639209) in  ??
#23 0x7ff625d49103     (0x142839103) in  ??
#24 0x7ff625d4c93c     (0x14283c93c) in  ??
#25 0x7ff626043aaa     (0x142b33aaa) in  ??
#26 0x7ff626017d53     (0x142b07d53) in  ??
#27 0x7ff6260197d9     (0x142b097d9) in  ??
#28 0x7ff6260176f0     (0x142b076f0) in  ??
#29 0x7ff625d5e6c4     (0x14284e6c4) in  ??
#30 0x7ff625d5ed74     (0x14284ed74) in  ??
#31 0x7ff625d83482     (0x142873482) in  ??
#32 0x7ff624902070     (0x1413f2070) in  ??
#33 0x7ff62490b198     (0x1413fb198) in  ??
#34 0x7ff6249ac1fe     (0x14149c1fe) in  ??
#35 0x7ff6244bb0c3     (0x140fab0c3) in  ??
#36 0x7ff624db7829     (0x1418a7829) in  ??
#37 0x7ff624dc8bd6     (0x1418b8bd6) in  ??
#38 0x7ff624dcace3     (0x1418bace3) in  ??
#39 0x7ff624fe7a10     (0x141ad7a10) in  ??
#40 0x7ff9d4cf51c5     (0x1800951c5) in std::_Func_impl_no_alloc<<lambda_699a8acb9c64ace7949dddbe338da309>, void>::_Do_call() at C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\functional:822
#41 0x7ff9d4d67640     (0x180107640) in endstone::detail::EndstoneServer::tick(unsigned int, std::function<void __cdecl(void)>&) at D:\a\endstone\endstone\src\endstone_core\server.cpp:467
#42 0x7ff9d4cf535f     (0x18009535f) in Level::tick() at D:\a\endstone\endstone\src\endstone_runtime\bedrock\world\level\level.cpp:30
#43 0x7ff624d40ce7     (0x141830ce7) in  ??
#44 0x7ff624d41c1f     (0x141831c1f) in  ??
#45 0x7ff624146511     (0x140c36511) in  ??
#46 0x7ff624138ac5     (0x140c28ac5) in  ??
#47 0x7ff6240aec1d     (0x140b9ec1d) in  ??
#48 0x7ffa7c149332     (0x180029332) in _recalloc
#49 0x7ffa7dc6257c     (0x18001257c) in BaseThreadInitThunk
#50 0x7ffa7ee2af27     (0x18005af27) in RtlUserThreadStart
@PrimeStrat PrimeStrat added the bug Something isn't working label Sep 14, 2024
@wu-vincent
Copy link
Member

Thanks. I can confirm this is a bug and will fix it later.

@wu-vincent wu-vincent self-assigned this Sep 14, 2024
@wu-vincent wu-vincent added this to the v0.5.4 milestone Sep 14, 2024
wu-vincent added a commit that referenced this issue Sep 16, 2024
@wu-vincent
Copy link
Member

I can confirm this is fixed in cc22e6e.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants