c++wxwidgets

wxWebRequest crashes at Release but works in Debug


I am using wxWebRequest to download a very small (1 KB) text file from the server with the following code:

auto WebRequest = wxWebSession::GetDefault().CreateRequest(this,
"https://www.pebytes.com/downloads/version.txt");
WebRequest.Start();

Bind(wxEVT_WEBREQUEST_STATE, &frmMacroLand::OnCheckNewVersion, this);

In Debug version all works well, but in Release version the application crashes and the event handler function is not even called:

void frmMacroLand::OnCheckNewVersion(wxWebRequestEvent &event)
{
    switch (event.GetState())
    {
        case wxWebRequest::State_Completed:
        wxInputStream* Input = event.GetResponse().GetStream();
        wxTextInputStream text(*Input );
    
        std::string str;
        while(Input->IsOk() && !Input->Eof()) //crashes here

The crash happens in mutex library in:

 void lock() {
        if (_Mtx_lock(_Mymtx()) != _Thrd_result::_Success) {
            // undefined behavior, only occurs for plain mutexes (N4950 [thread.mutex.requirements.mutex.general]/6)
            _STD _Throw_Cpp_error(_RESOURCE_DEADLOCK_WOULD_OCCUR);
        }

Any ideas?

By the way, I am using Windows 11 with MSVC and wxWidgets 3.2


Solution

  • You might be running into this notorious issue.