vslavik / poedit

Translations editor for Mac, Windows and Unix
https://poedit.net
MIT License
1.71k stars 274 forks source link

poedit 3 Crashed when trying to open a Cordwin project #725

Closed mfloryan closed 2 years ago

mfloryan commented 2 years ago

I noticed poedit (version 3) crashing when I try to "Translate Cordwin project".

Building from source on a MacOs I found the same behaviour.

The error I can see while debugging in XCode is: Thread 1: EXC_BAD_ACCESS (code=1, address=0x8) at http_client_macos.mm:247. From what I can see the m_impl variable is null

I tried stepping through the code and the potentially interesting place in the callstack is CrowdinClient::GetUserProjects() where m_api is a null pointer.

vslavik commented 2 years ago

Unfortunately, this isn't sufficient information to reproduce :( Rather obviously, it does not always crash on macOS, so whatever is happening is specific to some unknown circumstances. It could be macOS version (which you don't mention, but it's unlikely to be it), it could be something weird about your auth token. But I don't see what: if m_api is nullptr, the logic is going to ask you to sign in, not let you continue...

mfloryan commented 2 years ago

Yes, I'm sure this is specific to some circumstances on my machine. I think the auth token could be the culprit. If this is interesting enough to resolve and you could point me at a place in the code to start debugging from I'm happy to spend some more time finding the actual problem.

mfloryan commented 2 years ago

OK, Sorry for the initial noise. I was able to narrow it further to CrowdinClient::InitWithAuthToken

It seems like the cordwin token is expected to be a json object (in my case it's just a ~token~)

        auto token_json = json::parse(
            base64_decode_json_part(std::string(
                wxString(token).AfterFirst('.').BeforeFirst('.').utf8_str()
        )));

Since it's wrapped in a try/catch block I would expect to carry on but for some reason it just crashes the app without handling any exception.

vslavik commented 2 years ago

GitHub ate your token (which is good, it's sensitive information)… Could you share it with me by email, or share its general form while obfuscating the actual content?

In any case, thanks for figuring it out before I even got a chance to reply! This code is definitely bad and this information is enough to fix it to not crash. I'm just wondering how the bad token happened… It's supposed to handle tokens from older (pre-2.4) Poedit versions correctly. Could that be it, or did you recently login in Poedit 3 or 2.4?

mfloryan commented 2 years ago

Emailed the token. It's likely very old (pre 2.4) I haven't used Crowdin for a while and had old versions of poedit before although today I upgraded from 2.4

vslavik commented 2 years ago

Thanks a lot for your help with fixing this. Turns out it was a really embarrassing logic error...