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

5.1.0 Crash on Connect #358

Open
edcolmar opened this issue Nov 27, 2022 · 4 comments
Open

5.1.0 Crash on Connect #358

edcolmar opened this issue Nov 27, 2022 · 4 comments

Comments

@edcolmar
Copy link

edcolmar commented Nov 27, 2022

I'm updating my code to 5.1.0 and I'm getting a crash on connect. I'm using NativeClient within c++

Win10 development client build, VS 2022

Exception thrown: read access violation.
obj_ptr was nullptr.

Top of the call stack:

ExampleGameClient.exe!sio::socket::impl::on_message_packet(const sio::packet & p) Line 407 C++
[Inline Frame] ExampleGameClient.exe!sio::socket::on_message_packet(const sio::packet &) Line 639 C++
[Inline Frame] ExampleGameClient.exe!sio::client_impl_base::socket_on_message_packet(std::shared_ptrsio::socket &) Line 741 C++
ExampleGameClient.exe!sio::client_impl<websocketpp::clientwebsocketpp::config::asio_client>::on_decode(const sio::packet & p) Line 627 C++
[Inline Frame] ExampleGameClient.exe!std::_Func_class<void,sio::packet const &>::operator()(const sio::packet &) Line 968 C++
ExampleGameClient.exe!sio::packet_manager::put_payload(const std::string & payload) Line 529 C++

My Code:

FSIOConnectParams Params;
Params.AddressAndPort = InAddressAndPort;
//Params.Path = InPath;
//Params.AuthToken = InAuthToken;
Params.Query = USIOMessageConvert::JsonObjectToFStringMap(Query);
Params.Headers = USIOMessageConvert::JsonObjectToFStringMap(Headers);
NativeClient->Connect(Params);

Also maybe related?

NativeClient->OnConnectedCallback = [this](const FString& InSocketId, const FString& InSessionId )
{
FCULambdaRunnable::RunShortLambdaOnGameThread([this, InSocketId, InSessionId]
{
if (this)
{
bIsConnected = true;
SessionId = InSessionId;
SocketId = InSocketId;
bIsHavingConnectionProblems = false;
}
});
};

@edcolmar
Copy link
Author

I worked around this by adding a check for obj_ptr. It avoids the crash, and seems to be working. I'm not sure what effect this might have to the rest of the codebase.

sio_socket.cpp line 407:

               const object_message* obj_ptr = static_cast<const object_message*>(p.get_message().get());
                if (obj_ptr)
                {
                    const map<string, message::ptr>* values = &(obj_ptr->get_map());
                    auto it = values->find("sid");
                    if (it != values->end()) {
                        m_socket_id = static_pointer_cast<string_message>(it->second)->get_string();
                    }
                }

@getnamo
Copy link
Owner

getnamo commented Jan 18, 2023

Likely needs more context (e.g. socket.io host type) because it appears the packet you receive on connection has an empty object returned, which isn't standard socket.io server spec IIRC. The if barrier is valid workaround, but it does mean m_socket_id might not be filled in your connection setup, which means if you access socketid later on it will likely be invalid.

@edcolmar
Copy link
Author

Likely needs more context (e.g. socket.io host type) because it appears the packet you receive on connection has an empty object returned, which isn't standard socket.io server spec IIRC. The if barrier is valid workaround, but it does mean m_socket_id might not be filled in your connection setup, which means if you access socketid later on it will likely be invalid.

Thanks for the response. Is this due to incorrect setup client side? Or a server running an old/incompatible version?

@getnamo
Copy link
Owner

getnamo commented Jan 19, 2023

Suspecting a non standard server, e.g. a incomplete spec python server maybe? Check that it support socket.io protocol v3+

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

No branches or pull requests

2 participants