codecat / unet

Unified Lobby Networking library in C++, providing cross-play between Steam lobbies, Gog Galaxy lobbies, and Enet sockets.
MIT License
7 stars 1 forks source link

segfault in OnLobbyDataRetrieveSuccess #19

Open grasmanek94 opened 4 months ago

grasmanek94 commented 4 months ago
void Unet::LobbyListListener::OnLobbyDataRetrieveSuccess(const galaxy::api::GalaxyID& lobbyID)
{
    auto it = std::find(m_listDataFetch.begin(), m_listDataFetch.end(), lobbyID);
    if (it != m_listDataFetch.end()) {
        m_listDataFetch.erase(it);
    }

    xg::Guid unetGuid(galaxy::api::Matchmaking()->GetLobbyData(lobbyID, "unet-guid"));
    if (!unetGuid.isValid()) {
        m_self->m_ctx->GetCallbacks()->OnLogWarn("[Galaxy] unet-guid is not valid!");
        LobbyDataUpdated();
        return;
    }

    ServiceID newEntryPoint;
    newEntryPoint.Service = ServiceType::Galaxy;
    newEntryPoint.ID = lobbyID.ToUint64();
    m_self->m_requestLobbyList->Data->AddEntryPoint(unetGuid, newEntryPoint); // ->Data == nullptr

    LobbyDataUpdated();
}

m_self->m_requestLobbyList->Data->AddEntryPoint(unetGuid, newEntryPoint); // ->Data == nullptr

Code doesn't hit BP on AddServiceRequest where Data is assigned:

        ServiceRequest* AddServiceRequest(Service* service)
        {
            auto newServiceRequest = new ServiceRequest;
            newServiceRequest->Data = &m_result;
            m_requests.emplace_back(newServiceRequest); // Not hit
            return newServiceRequest;
        }

Reproduced with the CLI example (--galaxy .. ..) with side A doing: create test

side B: list list list (... callback info shows lobbies) data 0

(or `wait` also crashes) Full modified CLI source here: https://github.com/grasmanek94/UniverseLAN/blob/feature/unet-tests/Source/TestCases/Source-unet/TestCase_unet_cli_a.cxx (I don't use GOG galaxy client, I use built-in username/pw login method). Due the nature of my project I would be interested more in fixing it not only in the unet library (with a new release), but also try to find a way to make this work in the current application without forcing older games to update unet, if possible at all. I can modify the behaviour of the GOG Galaxy SDK side (my own implementation) to facilitate that, but I'm unsure why in a real/official GOG Galaxy SDK this segfault happens when using the CLI demo. The target SDK in this case is 1.139.2, didn't test other ones yet. Edit: Okay so the breakpoint is hit today after starting a debugging session and it works, without making any changes to the CLI code. I think this needs more investigation. Could it be an bug in the GOG Galaxy SDK instead?
codecat commented 4 months ago

Interesting. Judging purely by the pasted snippets, are you sure that m_requestLobbyList->Data is null and not m_requestLobbyList itself? If AddServiceRequest is never called, I think m_requestLobbyList is always going to be null.

grasmanek94 commented 4 months ago

I think m_requestLobbyList wasn't null, but I'm stomped as I can't reproduce it for now :( Maybe lets close this and reopen when I have more information, sorry for bothering!

codecat commented 4 months ago

Ah ok, that's unfortunate. I think we can keep this issue open in case someone else stumbles upon it.