Crash inside http_client constructor
I've been following the microsoft tutorial, how ever i'm getting a crash and I cannot figure it out.
I'm using visual studio 2017 with C++11
I've codded a function GetRequest() that do work when used in a new empty project, but when I try to use it on my Project (Very big project with millions of code lines). I'm crashing in the constructor of http_client, in the file xmemory0 line 118.
const uintptr_t _Ptr_container = _Ptr_user[-1];
This is a link to the callstack : https://i.imgur.com/lBm0Hv7.png
void RestManager::GetRequest()
{
auto fileStream = std::make_shared<ostream>();
// Open stream to output file.
pplx::task<void> requestTask = fstream::open_ostream(U("results.html")).then([=](ostream outFile)
{
*fileStream = outFile;
// Create http_client to send the request.
http_client client(U("XXX/XXX.svc/"));
// Build request URI and start the request.
uri_builder builder(U("/IsLive"));
builder.append_query(U("q"), U("cpprestsdk github"));
return client.request(methods::GET, builder.to_string());
})
// Handle response headers arriving.
.then([=](http_response response)
{
printf("Received response status code:%u\n", response.status_code());
// Write response body into the file.
return response.body().read_to_end(fileStream->streambuf());
})
// Close the file stream.
.then([=](size_t)
{
return fileStream->close();
});
// Wait for all the outstanding I/O to complete and handle any exceptions
try
{
requestTask.wait();
}
catch (const std::exception &e)
{
printf("Error exception:%s\n", e.what());
}
}
The wierd thing is that it's not crashing when i just make a main() that call this function. I guess it must be due to some memory issues, however I have no idea how could I debug that. Does anyone would have an idea about it?
Thanks and have a great day!
Did you find a solution? I am having the exact same problem, I'm just a newcomer to cpprestsdk and I'm trying to build the client sample exactly as it comes. http_client client(U("http://www.bing.com/")); crashes in the exact same line as yours. In the 64-bit version however, it crashes in _container_base12::Orphan_all() since _Myproxy value is 0xcccccccccccccccc.
Has anyone been able to resolve this crash? Having the same issue.
I have the same issue. Does anyone would have an idea about it?
Project Properties > Configuration > vcpkg > Vcpkg configuration > Debug solved problem for me