Assert(released == false) throws when uploading a file

May 10, 2013 at 6:01 PM
I have been getting assertions when trying to upload a file via PUT. I am simply using concurrency::streams::basic_istream to upload a file with http_client. The assertions get thrown
when calling client.request(request).get(); Ignoring the assertions successfully uploads the file.

I am checking that the file_stream is valid and ready before uploading.

The 3 assertions that get thrown in debug mode when trying to upload a file are lines 967, 961, and 913 in http_client.cpp souce file. All the assertions report "released == false"

Can you tell me what is wrong with this? Any workarounds?

Windows 8, Visual Studio 2012, C++ REST SDK 0.6. x64 and x86 Debug.
May 13, 2013 at 5:01 PM
Hi trollbyte,

It's hard to say what is going wrong, and thus to suggest a workaround -- this isn't anything we've seen in our testing, so far. At first glance, it seems consistent with your being successful in uploading the file by ignoring the assertions, because I believe the assertions are protecting against a situation where there would be a memory leak rather than double-deletion. Memory leaks, of course, don't get in the way of the functionality until you run out of memory...

If you could provide more details (without disclosing any trade secrets or other sensitive information) about how you are uploading (are you using PUT or POST, is the server using HTTP or HTTPS, for example, are you using a proxy, authentication, etc.), we could hopefully reproduce it and look into it.

Also, please file this as an issue -- it should be tracked as such.


May 13, 2013 at 5:45 PM
Hi trollbyte,

If you can share code particularly the portions where you construct the http_client and build the http_request before the client.request method would be helpful.

Thanks, Steve
May 13, 2013 at 5:52 PM
Edited May 13, 2013 at 5:54 PM
Yes, thanks for the quick responses. I will also file an issue for this as suggested.

I am using a proxy, I am using HTTPS, and I am using a PUT to upload the file.
This is the code portion were I construct the http_client and http_request:
//Open the file for upload
concurrency::streams::basic_istream<unsigned char> file_stream = concurrency::streams::file_stream<unsigned char>::open_istream(localFilePath).get();

if(file_stream.is_valid() == false)
    return FALSE;

web::http::client::web_proxy web_proxy(web::http::client::web_proxy::web_proxy_mode::use_auto_discovery);
    web::http::client::http_client_config client_config;

web::http::uri_builder request_uri;
request_uri.append_path(remoteFilePath, true);

web::http::http_request request(web::http::methods::PUT);

    //Get the Response
    web::http::client::http_client client(L"", client_config);
        web::http::http_response response = client.request(request).get(); //Throws Assert!

    if(response.status_code() == web::http::status_codes::OK)
        //Parse JSON
        const web::json::value& json = response.extract_json().get();
        return TRUE;
catch(web::http::http_exception& e)
    const std::error_code errorCode = e.error_code();
    const char* what = e.what();
return FALSE;
May 13, 2013 at 5:57 PM
One more detail: does the response have a body if there's an error?

May 13, 2013 at 6:02 PM
Yes, when the Assertions are thrown, I still get the expected JSON response as if it was successful. The file also seems to upload successfully as well.