EndstoneMC / endstone

Endstone - High-level Plugin API for Modding Bedrock Dedicated Servers (BDS), in both Python and C++.
http://endstone.dev/
Apache License 2.0
227 stars 21 forks source link

[bug] Creating a form without a on submit callback crashes the server #32

Closed zSALLAZAR closed 1 month ago

zSALLAZAR commented 1 month ago

Describe the bug Creating a form without a on submit callback crashes the server

To Reproduce Steps to reproduce the behavior:

  1. Create a ActionForm
  2. Add buttons
  3. Click on a button
  4. See error

Expected behavior The form should just close

Screenshots If applicable, add screenshots to help explain your problem.

Details (please complete the following information):

Additional context Add any other context about the problem here.

wu-vincent commented 1 month ago

I can't reproduce it locally. Could you attach the screenshots of the crash logs and your code? That will be helpful.

zSALLAZAR commented 1 month ago

Code:

    bool onCommand(endstone::CommandSender &sender, const endstone::Command &command, const std::vector<std::string> &args) override {
        if (command.getName() == "form") {
            sender.asPlayer()->sendForm(endstone::ActionForm().setTitle("Title").addButton("Button1").addButton("Button2"));
            return true;
        }
        return false;
    }

Crash logs:

=== ENDSTONE CRASHED! - PLEASE REPORT THIS AS AN ISSUE ON GITHUB ===
Operation system: Windows
Endstone version: 0.5.0
Api version     : 0.5
Description     : Exception unhandled: 0xc0000005
Stack trace (most recent call first):
#0  0x7fff7339858f     (0x1800c858f) in endstone::detail::`anonymous namespace'::exception_filter(_EXCEPTION_POINTERS*) at D:\a\endstone\endstone\src\endstone_runtime\windows\signal_handler.cpp:51
#1  0x7ff808f30bbb     (0x180160bbb) in UnhandledExceptionFilter
#2  0x7ff80b4f96bc     (0x1800a96bc) in RtlCopyMemory
#3  0x7ff80b4df666     (0x18008f666) in __C_specific_handler
#4  0x7ff80b4f504e     (0x1800a504e) in __chkstk
#5  0x7ff80b46e865     (0x18001e865) in RtlFindCharInUnicodeString
#6  0x7ff80b4f403d     (0x1800a403d) in KiUserExceptionDispatcher
#7  0x7fffcb277c22     (0x180007c22) in  ??
#8  0x7fff733ab34a     (0x1800db34a) in std::_Visit_impl<4, void, std::_Meta_list<std::integer_sequence<unsigned __int64, 0>, std::integer_sequence<unsigned __int64, 1>, std::integer_sequence<unsigned __int64, 2>, std::intege
r_sequence<unsigned __int64, 3> >, entt::overloaded<<lambda_ab72ef6a8ccd940d1ccdc9e61dee68e8>, <lambda_92b273042a7e6f9f7f66ba4d1ae6f9e2>, <lambda_eb2257babaed0a91505dcfc65ef256b2> >, std::variant<endstone::MessageForm, endstone::ActionForm, endstone::ModalForm> &>(entt::overloaded<<lambda_ab72ef6a8ccd940d1ccdc9 at C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\variant:1659
#9  0x7fff733bc8bd     (0x1800ec8bd) in endstone::detail::EndstonePlayer::onFormResponse(int, int) at D:\a\endstone\endstone\src\endstone_core\player.cpp:575
#10 0x7fff73336451     (0x180066451) in std::_Visit_impl<27, void, std::_Meta_list<std::integer_sequence<unsigned __int64, 0>, std::integer_sequence<unsigned __int64, 1>, std::integer_sequence<unsigned __int64, 2>, std::integ
er_sequence<unsigned __int64, 3>, std::integer_sequence<unsigned __int64, 4>, std::integer_sequence<unsigned __int64, 5>, std::integer_sequence<unsigned __int64, 6>, std::integer_sequence<unsigned __int64, 7>, std::integer_sequence<unsigned __int64, 8>, std::integer_sequence<unsigned __int64, 9>, std::integer_s at C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\variant:1659
#11 0x7fff7335906b     (0x18008906b) in PlayerEventCoordinator::sendEvent(EventRef<PlayerGameplayEvent<void> >&) at D:\a\endstone\endstone\src\endstone_runtime\bedrock\world\events\event_coordinator.cpp:133
#12 0x7ff60b68d192     (0x14088d192) in public: virtual void __cdecl ServerNetworkHandler::handle(class NetworkIdentifier const & __ptr64,class ModalFormResponsePacket const & __ptr64) __ptr64
#13 0x7ff60b6142be     (0x1408142be) in private: bool __cdecl NetworkSystem::_sortAndPacketizeEvents(class NetworkConnection & __ptr64,class std::chrono::time_point<struct std::chrono::steady_clock,class std::chrono::duration<__int64,struct std::ratio<1,1000000000> > >) __ptr64
#14 0x7ff60b60b143     (0x14080b143) in <lambda_8bb3820396aae5a3b1b3170aaa94fbae>::operator()
#15 0x7ff60b628777     (0x140828777) in public: void __cdecl NetworkSystem::runEvents(bool) __ptr64
#16 0x7ff60c60a433     (0x14180a433) in public: bool __cdecl Minecraft::update(void) __ptr64
#17 0x7ff60ba78e51     (0x140c78e51) in private: void __cdecl ServerInstance::_update(void) __ptr64
#18 0x7ff60ba6aa65     (0x140c6aa65) in <lambda_261fc769b4b17f58193d57d5f3ee7db9>::operator()
#19 0x7ff60b9e38dd     (0x140be38dd) in std::thread::_Invoke<std::tuple<<lambda_261fc769b4b17f58193d57d5f3ee7db9> >,0>
#20 0x7ff8087c9332     (0x180029332) in _recalloc
#21 0x7ff809fb257c     (0x18001257c) in BaseThreadInitThunk
#22 0x7ff80b4aaf27     (0x18005af27) in RtlUserThreadStart
wu-vincent commented 1 month ago

Thanks, I am able to reproduce it now. I will look into it.

wu-vincent commented 1 month ago

Can confirm this is now fixed in https://github.com/EndstoneMC/endstone/commit/89058cdf750c02f8eb9e71cd976ab452ab47af30. Thanks for reporting this! I will shortly make another release.