Source-Python-Dev-Team / Source.Python

This plugin aims to use boost::python and create an easily accessible wrapper around the Source Engine API for scripter use.
http://forums.sourcepython.com
GNU General Public License v3.0
164 stars 32 forks source link

RuntimeError: CHECK failed: (to->GetDescriptor()) == (descriptor): Tried to merge messages of different types. #451

Closed Phoross closed 2 years ago

Phoross commented 2 years ago

I'm using Source.Python to run a WCS server and everything was working fine yesterday but starting today I'm having an error popping up endlessly when I try to use the command 'wcs' which open a radio menu with all the options. The error is the following one :

[libprotobuf FATAL ..\src\google\protobuf\reflection_ops.cc:58] CHECK failed: (to->GetDescriptor()) == (descriptor): Tried to merge messages of different types.
[Source.Python]
[SP] Caught an Exception:
Traceback (most recent call last):
  File "..\addons\source-python\packages\source-python\listeners\tick.py", line 79, in _tick
    self.pop(0).execute()
  File "..\addons\source-python\packages\source-python\listeners\tick.py", line 160, in execute
    return self.callback(*self.args, **self.kwargs)
  File "..\addons\source-python\plugins\wcs\wcs.py", line 372, in _send_message_and_remove
    message.send(wcsplayer.index, **kwargs)
  File "..\addons\source-python\packages\source-python\menus\base.py", line 174, in send
    queue._refresh()
  File "..\addons\source-python\packages\source-python\menus\queue.py", line 105, in _refresh
    menu._refresh(self._index)
  File "..\addons\source-python\packages\source-python\menus\base.py", line 104, in _refresh
    self._send(player_index)
  File "..\addons\source-python\packages\source-python\menus\radio.py", line 120, in _send
    ShowMenu(*self._build(player_index)).send(player_index)
  File "..\addons\source-python\packages\source-python\messages\base.py", line 232, in send
    user_message.send()

RuntimeError: CHECK failed: (to->GetDescriptor()) == (descriptor): Tried to merge messages of different types.

It doesn't happen until I type the command in the chat and for then on it's non stop in the console. A change in Source.Python that may be causing this? Don't know how to fix it :/

jordanbriere commented 2 years ago

What is the output of sp info?

I'm unable to reproduce and the menu is working fine:

wcs

EDIT: I was able to reproduce with SourceMod 1.11. Works fine with SourceMod 1.10.

Phoross commented 2 years ago

Here is my output for sp info : `sp info [Source.Python] IMPORTANT: Please copy the full output.

Checksum : df92d21fc1e74dc058c36de1cef0cf27 Date : 2022-07-24 11:12:59.607624 OS : Windows-10-10.0.19041 Game : csgo SP version : 714 Github commit : d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb Server plugins: 00: Metamod:Source 1.11.0-dev+1148 01: Source.Python, (C) 2012-2021, Source.Python Team. SP plugins: 00: es_emulator, https://github.com/Ayuto/EventScripts-Emulator 01: wcs, 2022.02.22-1, https://forums.sourcepython.com/viewtopic.php?f=7&t=1925 02: commandsx --------------------------------------------------------`

I'll try and replace SourceMod with SourceMod 1.10 and see if that fixes it!

EDIT: Just tried with 1.10 and everything works fine!

Phoross commented 2 years ago

Do I leave the issue open until there is a fix for 1.11 or is that not necessary?

jordanbriere commented 2 years ago

Do I leave the issue open until there is a fix for 1.11 or is that not necessary?

We can leave it open until it is actually fixed so that others that encounter the same can find it. Not sure if that is something they will address on their end, or something that we will have to workaround on our (assuming we even can) but, in the meantime, if you wish to run the latest version of SourceMod, you could try the following plugin that seems to hack its way through from the minimal testings I just did:

from core import GAME_NAME, PLATFORM
from memory import find_binary, Convention, DataType
from memory.hooks import PreHook
from _messages import ProtobufMessage
from paths import ADDONS_PATH

# static void ReflectionOps::Merge(const Message& from, Message* to)
@PreHook(
    find_binary(
        ADDONS_PATH / 'sourcemod/bin/sourcemod.2.' +
        f'{GAME_NAME}.{"so" if PLATFORM == "linux" else "dll"}'
    )[
        {'windows':
            b'\x55\x8B\xEC\x6A\xFF\x68\x2A\x2A\x2A\x2A\x64\xA1\x00\x00\x00\x00' +
            b'\x50\x83\xEC\x70\xA1\x2A\x2A\x2A\x2A\x33\xC5\x89\x45\xF0\x53\x56' +
            b'\x57\x50\x8D\x45\xF4\x64\xA3\x00\x00\x00\x00\x8B\x5D\x08\x33\xC0',
        'linux':
            '_ZN6google8protobuf8internal13ReflectionOps5MergeERKNS0_7MessageEPS3_'
        }[PLATFORM]
    ].make_function(
        Convention.CDECL,
        [DataType.POINTER, DataType.POINTER],
        DataType.VOID
    )
)
def _(stack_data):
    ProtobufMessage.parse_to_abstract_pointer(
        ProtobufMessage.from_abstract_pointer(stack_data[0]),
        stack_data[1]
    )

    return False
jordanbriere commented 2 years ago

This issue was fixed into https://github.com/alliedmodders/sourcemod/pull/1812 and is available in their latest development build.