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

[bug] Unknown error #115

Open
pgrd1 opened this issue Dec 28, 2024 · 9 comments
Open

[bug] Unknown error #115

pgrd1 opened this issue Dec 28, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@pgrd1
Copy link

pgrd1 commented Dec 28, 2024

Describe the bug
Addon causes unknown error

To Reproduce
It appears to occur when anti-cheat addon detects a hack user.

Expected behavior
A clear and concise description of what you expected to happen. Below is a part of the anti cheat code.

import { EntityDamageCause, EntityEquippableComponent, EquipmentSlot, ItemDurabilityComponent, Player, system, world } from "@minecraft/server";
import { isAdmin, flag } from "../../Assets/Util";
import { MinecraftEntityTypes, MinecraftItemTypes } from "../../node_modules/@minecraft/vanilla-data/lib/index";
import { registerModule } from "../Modules.js";
import { AnimationControllerTags, MatrixUsedTags } from "../../Data/EnumData";
/**
 * @author jasonlaubb
 * @description Detect if player try to use disabler to bypass anti-cheat
 * Thanks for RaMi helps to test!
 */
function intickEvent(config, player) {
    if (isAdmin(player) || player.hasTag(MatrixUsedTags.disabler) || !player.hasTag(AnimationControllerTags.alive))
        return;
    if (player.isGliding) {
        const elytra = player.getComponent(EntityEquippableComponent.componentId)?.getEquipment(EquipmentSlot.Chest);
        const durability = elytra?.getComponent(ItemDurabilityComponent.componentId);
        if (!durability)
            return;
        if (elytra?.typeId != MinecraftItemTypes.Elytra || (elytra?.typeId == MinecraftItemTypes.Elytra && durability.maxDurability - durability.damage <= 1)) {
            player.addTag(MatrixUsedTags.disabler);
            system.runTimeout(() => player.removeTag(MatrixUsedTags.disabler), 10);
            player.teleport(player.lastNonGlidingPoint);
            flag(player, "Disabler", "A", config.antiDisabler.maxVL, config.antiDisabler.punishment, undefined);
        }
    }
    else {
        player.lastNonGlidingPoint = player.location;
    }
}
function doubleEvent(config, damagingEntity, hurtEntity) {
    if (hurtEntity.id == damagingEntity.id) {
        const location = hurtEntity.location;
        system.run(() => hurtEntity.teleport(location));
        flag(hurtEntity, "Disabler", "B", config.antiDisabler.maxVL, config.antiDisabler.punishment, undefined);
    }
}
function tripleEvent({ player, initialSpawn }) {
    if (!initialSpawn)
        return;
    player.removeTag(MatrixUsedTags.disabler);
}
registerModule("antiDisabler", false, [], {
    intick: async (config, player) => intickEvent(config, player),
    tickInterval: 1,
}, {
    worldSignal: world.afterEvents.entityHurt,
    playerOption: { entityTypes: [MinecraftEntityTypes.Player] },
    then: async (config, { damageSource: { damagingEntity, damagingProjectile, cause }, hurtEntity }) => {
        if (!(hurtEntity instanceof Player) || isAdmin(hurtEntity) || !damagingEntity || cause != EntityDamageCause.entityAttack || damagingProjectile || !damagingEntity)
            return;
        doubleEvent(config, damagingEntity, hurtEntity);
    },
}, {
    worldSignal: world.afterEvents.playerSpawn,
    playerOption: { entityTypes: [MinecraftEntityTypes.Player] },
    then: async (_config, event) => {
        tripleEvent(event);
    },
});

function flag(player, modules, type, maxVL, punishment, infos) {
    const config = c();
    // Skip if the player is in the bypass list
    if (config.autoPunishment.bypasslist.includes(player.id))
        return;
    system.run(() => {
        Vl[player.id] ??= {};
        Vl[player.id][modules] ??= 0;
        try {
            Vl[player.id][modules]++;
        }
        catch { }
        const flagMsg = new rawstr(true).tra("flag.style", player.name, modules, type, Vl[player.id][modules]);
        if (config.logsettings.logCheatFlag)
            saveLog("Flag", player.name, `${modules} ${type} (x${Vl[player.id][modules]})`);
        if (infos !== undefined)
            flagMsg.str("\n" + formatInformation(infos));
        if (punishment && Vl[player.id][modules] > maxVL && !config.autoPunishment.observationMode) {
            let punishmentDone = false;
            const banrun = config.banrun.command;
            if (config.commands.banrun && banrun.length > 0 && ["kick", "ban"].includes(punishment)) {
                player.runCommand(banrun);
            }
            else {
                switch (punishment) {
                    case "kick": {
                        punishmentDone = true;
                        if (config.logsettings.logCheatPunishment)
                            saveLog("Kick", player.name, `${modules} ${type}`);
                        player.runCommand(`kick "${player.name}" ${config.autoPunishment.kick.reason}`)
                        flagMsg.str("§3 ").tra("util.formkick", player.name);
                        break;
                    }
                    case "ban": {
                        punishmentDone = true;
                        if (config.logsettings.logCheatPunishment)
                            saveLog("Ban", player.name, `${modules} ${type}`);
                        player.runCommand(`ban2 "${player.name}" "${config.autoPunishment.ban.reason} 99999d"`)
                        flagMsg.str("§3 ").tra("util.formban", player.name);
                        break;
                    }
                    case "tempkick": {
                        punishmentDone = true;
                        if (config.logsettings.logCheatPunishment)
                            saveLog("TempKick", player.name, `${modules} ${type}`);
                        // Tempkick the player, espectially for local world.
                        player.runCommand(`ban2 "${player.name}" "${config.autoPunishment.ban.reason} 3d"`)
                        break;
                    }
                }
            }
            if (punishmentDone) {
                Vl[player.id][modules] = 0;
            }
        }
        if (config.autoPunishment.silentMode)
            return;
        const flagMode = world.getDynamicProperty("flagMode") ?? config.flagMode;
        switch (flagMode) {
            case "tag": {
                const targets = world.getPlayers({ tags: ["matrix:notify"] });
                targets.forEach((players) => {
                    if (config.soundEffect)
                        players.playSound("note.pling", { volume: 1.0, pitch: 3.0 });
                    players.sendMessage(flagMsg.parse());
                });
                break;
            }
            case "bypass": {
                const targets = world.getPlayers({ excludeNames: [player.name] });
                targets.forEach((players) => {
                    if (config.soundEffect)
                        players.playSound("note.pling", { volume: 1.0, pitch: 3.0 });
                    players.sendMessage(flagMsg.parse());
                });
                break;
            }
            case "admin": {
                const allPlayers = world.getAllPlayers();
                const targets = allPlayers.filter((players) => isAdmin(players));
                targets.forEach((players) => {
                    if (config.soundEffect)
                        players.playSound("note.pling", { volume: 1.0, pitch: 3.0 });
                    players.sendMessage(flagMsg.parse());
                });
                break;
            }
            case "none": {
                break;
            }
            default: {
                world.sendMessage(flagMsg.parse());
                const targets = world.getAllPlayers();
                targets.forEach((players) => {
                    if (config.soundEffect)
                        players.playSound("note.pling", { volume: 1.0, pitch: 3.0 });
                });
                break;
            }
        }
    });
}

Screenshots

=== ENDSTONE CRASHED! - PLEASE REPORT THIS AS AN ISSUE ON GITHUB ===
Operation system: Windows
Endstone version: 0.5.6
Api version     : 0.5
Description     : Exception unhandled: 0xc0000005
Stack trace (most recent call first):
[0 ] 0x7ff9dea68a5f     (0x1800d8a5f) in endstone::detail::`anonymous namespace'::exception_filter(_EXCEPTION_POINTERS*) at D:\a\endstone\endstone\src\endstone_runtime\windows\signal_handler.cpp:53
[1 ] 0x7ffaa055ca1b     (0x18016ca1b) in UnhandledExceptionFilter
[2 ] 0x7ffaa2eb9abc     (0x1800a9abc) in memmove
[3 ] 0x7ffaa2e9f7c6     (0x18008f7c6) in __C_specific_handler
[4 ] 0x7ffaa2eb543e     (0x1800a543e) in __chkstk
[5 ] 0x7ffaa2e2e885     (0x18001e885) in RtlFindCharInUnicodeString
[6 ] 0x7ffaa2eb443d     (0x1800a443d) in KiUserExceptionDispatcher
[7 ] 0x7ff9deab02d6     (0x1801202d6) in endstone::detail::EndstoneServer::broadcast(std::variant<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, endstone::Translatable>&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&) at D:\a\endstone\endstone\src\endstone_core\server.cpp:331
[8 ] 0x7ff9df024c01     (0x180164c01) in PyInit_endstone_python
[9 ] 0x7ff9defc5355     (0x180105355) in PyInit_endstone_python
[10] 0x7ff9def3bed1     (0x18007bed1) in PyInit_endstone_python
[11] 0x7ff9f556005d     (0x1800a005d) in _PyArg_ParseTuple_SizeT
[12] 0x7ff9f54dc200     (0x18001c200) in _PyObject_MakeTpCall
[13] 0x7ff9f56644f4     (0x1801a44f4) in _Py_gitversion
[14] 0x7ff9f552a91c     (0x18006a91c) in _PyEval_EvalFrameDefault
[15] 0x7ff9f5527a33     (0x180067a33) in _PyFunction_Vectorcall
[16] 0x7ff9f5562b7e     (0x1800a2b7e) in PyFloat_FromDouble
[17] 0x7ff9f5553f4b     (0x180093f4b) in PyVectorcall_Call
[18] 0x7ff9f5553d4e     (0x180093d4e) in _PyObject_Call
[19] 0x7ff9defa3d2d     (0x1800e3d2d) in PyInit_endstone_python
[20] 0x7ff9df1c141b     (0x18030141b) in PyInit_endstone_python
[21] 0x7ff9deaf726b     (0x18016726b) in endstone::PluginCommand::execute(endstone::PluginCommand*, endstone::CommandSender&) at D:\a\endstone\endstone\include\endstone\command\plugin_command.h:43
[22] 0x7ff9deb8e5bd     (0x1801fe5bd) in endstone::detail::MinecraftCommandAdapter::execute(CommandOrigin&, CommandOutput&) at D:\a\endstone\endstone\src\endstone_core\command\minecraft_command_adapter.cpp:52
[23] 0x7ff7e385c798     (0x14137c798) in  ??
[24] 0x7ff9de9e1488     (0x180051488) in Command::run(CommandOrigin&, CommandOutput&) at D:\a\endstone\endstone\src\endstone_runtime\bedrock\server\commands\command.cpp:38
[25] 0x7ff7e3a10aa6     (0x141530aa6) in  ??
[26] 0x7ff9de9ec4e8     (0x18005c4e8) in MinecraftCommands::executeCommand(CommandContext&, bool) at D:\a\endstone\endstone\src\endstone_runtime\bedrock\server\commands\minecraft_commands.cpp:64
[27] 0x7ff7e3e8335c     (0x1419a335c) in  ??
[28] 0x7ff7e3d2491a     (0x14184491a) in  ??
[29] 0x7ff7e3e2bcf7     (0x14194bcf7) in  ??
[30] 0x7ff7e590fe2d     (0x14342fe2d) in  ??
[31] 0x7ff7e5913f2f     (0x143433f2f) in  ??
[32] 0x7ff7e59cfbea     (0x1434efbea) in  ??
[33] 0x7ff7e599b646     (0x1434bb646) in  ??
[34] 0x7ff7e599d04e     (0x1434bd04e) in  ??
[35] 0x7ff7e599af40     (0x1434baf40) in  ??
[36] 0x7ff7e59285ad     (0x1434485ad) in  ??
[37] 0x7ff7e5928fbf     (0x143448fbf) in  ??
[38] 0x7ff7e595a956     (0x14347a956) in  ??
[39] 0x7ff7e44edcef     (0x14200dcef) in  ??
[40] 0x7ff7e44fcbec     (0x14201cbec) in  ??
[41] 0x7ff7e45dc2d0     (0x1420fc2d0) in  ??
[42] 0x7ff7e4777439     (0x142297439) in  ??
[43] 0x7ff7e478e4d6     (0x1422ae4d6) in  ??
[44] 0x7ff7e478f9f3     (0x1422af9f3) in  ??
[45] 0x7ff7e4a88fc6     (0x1425a8fc6) in  ??
[46] 0x7ff9dea35005     (0x1800a5005) 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
[47] 0x7ff9deab6fc0     (0x180126fc0) in endstone::detail::EndstoneServer::tick(unsigned int, std::function<void __cdecl(void)>&) at D:\a\endstone\endstone\src\endstone_core\server.cpp:503
[48] 0x7ff9dea3517f     (0x1800a517f) in Level::tick() at D:\a\endstone\endstone\src\endstone_runtime\bedrock\world\level\level.cpp:29
[49] 0x7ff7e4702c09     (0x142222c09) in  ??
[50] 0x7ff7e37ff07b     (0x14131f07b) in  ??
[51] 0x7ff7e37f2c3f     (0x141312c3f) in  ??
[52] 0x7ff7e3748a7d     (0x141268a7d) in  ??
[53] 0x7ffaa08f9332     (0x180029332) in _recalloc
[54] 0x7ffaa2a4259c     (0x18001259c) in BaseThreadInitThunk
[55] 0x7ffaa2e6af37     (0x18005af37) in RtlUserThreadStart

Details (please complete the following information):

  • OS: Windows
  • Endstone Version: 0.5.6

Additional context
It was a bug that kept happening from version 0.5+

@pgrd1 pgrd1 added the bug Something isn't working label Dec 28, 2024
@pgrd1
Copy link
Author

pgrd1 commented Dec 28, 2024

Another crash log that occurs when /reload

=== ENDSTONE CRASHED! - PLEASE REPORT THIS AS AN ISSUE ON GITHUB ===
Operation system: Windows
Endstone version: 0.5.6
Api version     : 0.5
Description     : Exception unhandled: 0xc0000005
Stack trace (most recent call first):
[0 ] 0x7ffa13df8a5f     (0x1800d8a5f) in endstone::detail::`anonymous namespace'::exception_filter(_EXCEPTION_POINTERS*) at D:\a\endstone\endstone\src\endstone_runtime\windows\signal_handler.cpp:53
[1 ] 0x7ffaa055ca1b     (0x18016ca1b) in UnhandledExceptionFilter
[2 ] 0x7ffaa2eb9abc     (0x1800a9abc) in memmove
[3 ] 0x7ffaa2e9f7c6     (0x18008f7c6) in __C_specific_handler
[4 ] 0x7ffaa2eb543e     (0x1800a543e) in __chkstk
[5 ] 0x7ffaa2e2e885     (0x18001e885) in RtlFindCharInUnicodeString
[6 ] 0x7ffaa2eb443d     (0x1800a443d) in KiUserExceptionDispatcher
[7 ] 0x7ff6c98364a3     (0x141bc64a3) in  ??
[8 ] 0x7ff6c9f07413     (0x142297413) in  ??
[9 ] 0x7ff6c9f1e4d6     (0x1422ae4d6) in  ??
[10] 0x7ff6c9f1fa0f     (0x1422afa0f) in  ??
[11] 0x7ff6ca218fc6     (0x1425a8fc6) in  ??
[12] 0x7ffa13dc5005     (0x1800a5005) 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
[13] 0x7ffa13e46fc0     (0x180126fc0) in endstone::detail::EndstoneServer::tick(unsigned int, std::function<void __cdecl(void)>&) at D:\a\endstone\endstone\src\endstone_core\server.cpp:503
[14] 0x7ffa13dc517f     (0x1800a517f) in Level::tick() at D:\a\endstone\endstone\src\endstone_runtime\bedrock\world\level\level.cpp:29
[15] 0x7ff6c9e92c09     (0x142222c09) in  ??
[16] 0x7ff6c8f8f07b     (0x14131f07b) in  ??
[17] 0x7ff6c8f82c3f     (0x141312c3f) in  ??
[18] 0x7ff6c8ed8a7d     (0x141268a7d) in  ??
[19] 0x7ffaa08f9332     (0x180029332) in _recalloc
[20] 0x7ffaa2a4259c     (0x18001259c) in BaseThreadInitThunk
[21] 0x7ffaa2e6af37     (0x18005af37) in RtlUserThreadStart

@ye111566

This comment was marked as off-topic.

@ye111566

This comment was marked as off-topic.

@ye111566

This comment was marked as off-topic.

@smartcmd
Copy link
Contributor

smartcmd commented Jan 1, 2025

Best chatgpt user 🤣

@Cdm2883
Copy link

Cdm2883 commented Jan 1, 2025

Best 文心一言 user 🤣

@wu-vincent
Copy link
Member

Thank you for the issue. Unfortunately, I can't go through all your code to pinpoint the problem. I need a minimal example that can reliably reproduce the issue. Please provide a simplified version of your code.

@wu-vincent
Copy link
Member

Another crash log that occurs when /reload

=== ENDSTONE CRASHED! - PLEASE REPORT THIS AS AN ISSUE ON GITHUB ===
Operation system: Windows
Endstone version: 0.5.6
Api version     : 0.5
Description     : Exception unhandled: 0xc0000005
Stack trace (most recent call first):
[0 ] 0x7ffa13df8a5f     (0x1800d8a5f) in endstone::detail::`anonymous namespace'::exception_filter(_EXCEPTION_POINTERS*) at D:\a\endstone\endstone\src\endstone_runtime\windows\signal_handler.cpp:53
[1 ] 0x7ffaa055ca1b     (0x18016ca1b) in UnhandledExceptionFilter
[2 ] 0x7ffaa2eb9abc     (0x1800a9abc) in memmove
[3 ] 0x7ffaa2e9f7c6     (0x18008f7c6) in __C_specific_handler
[4 ] 0x7ffaa2eb543e     (0x1800a543e) in __chkstk
[5 ] 0x7ffaa2e2e885     (0x18001e885) in RtlFindCharInUnicodeString
[6 ] 0x7ffaa2eb443d     (0x1800a443d) in KiUserExceptionDispatcher
[7 ] 0x7ff6c98364a3     (0x141bc64a3) in  ??
[8 ] 0x7ff6c9f07413     (0x142297413) in  ??
[9 ] 0x7ff6c9f1e4d6     (0x1422ae4d6) in  ??
[10] 0x7ff6c9f1fa0f     (0x1422afa0f) in  ??
[11] 0x7ff6ca218fc6     (0x1425a8fc6) in  ??
[12] 0x7ffa13dc5005     (0x1800a5005) 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
[13] 0x7ffa13e46fc0     (0x180126fc0) in endstone::detail::EndstoneServer::tick(unsigned int, std::function<void __cdecl(void)>&) at D:\a\endstone\endstone\src\endstone_core\server.cpp:503
[14] 0x7ffa13dc517f     (0x1800a517f) in Level::tick() at D:\a\endstone\endstone\src\endstone_runtime\bedrock\world\level\level.cpp:29
[15] 0x7ff6c9e92c09     (0x142222c09) in  ??
[16] 0x7ff6c8f8f07b     (0x14131f07b) in  ??
[17] 0x7ff6c8f82c3f     (0x141312c3f) in  ??
[18] 0x7ff6c8ed8a7d     (0x141268a7d) in  ??
[19] 0x7ffaa08f9332     (0x180029332) in _recalloc
[20] 0x7ffaa2a4259c     (0x18001259c) in BaseThreadInitThunk
[21] 0x7ffaa2e6af37     (0x18005af37) in RtlUserThreadStart

The stack traces leading up to the crash handler appear to originate within BDS itself, not Endstone. Specifically, these entries:

[7 ] 0x7ff6c98364a3 (0x141bc64a3) in ??
[8 ] 0x7ff6c9f07413 (0x142297413) in ??
[9 ] 0x7ff6c9f1e4d6 (0x1422ae4d6) in ??
[10] 0x7ff6c9f1fa0f (0x1422afa0f) in ??
[11] 0x7ff6ca218fc6 (0x1425a8fc6) in ??

indicate that the crash is likely caused by an issue within BDS itself.

@pgrd1
Copy link
Author

pgrd1 commented Jan 1, 2025

Sorry code is more than 10000 lines for both addon and plugin, so I'm not sure where it comes from in detail. Do you know the cause of the error that comes to mind?

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

5 participants