Я пытаюсь использовать библиотеку sdk C ++ для хранения Azure с Unreal Engine 4 для загрузки изображений в облако Azure. Библиотека построена с помощью vcpkg, и dll связаны динамически. Вот упрощенный пример кода, который я использую.
THIRD_PARTY_INCLUDES_START
#pragma warning(disable:4668)
#pragma warning(disable:4005) // 'TEXT': macro redefinition
#include <was/storage_account.h>
#include <was/blob.h>
#include <cpprest/filestream.h>
#include <cpprest/containerstream.h>
THIRD_PARTY_INCLUDES_END
const utility::string_t storage_connection_string(U("DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=MyAccountKey;EndpointSuffix=core.windows.net"));
void AAwsTest2GameModeBase::StartPlay() {
try
{
// Retrieve storage account from connection string.
azure::storage::cloud_storage_account storage_account = azure::storage::cloud_storage_account::parse(storage_connection_string);
// Create the blob client.
azure::storage::cloud_blob_client blob_client = storage_account.create_cloud_blob_client();
// Retrieve a reference to a container.
azure::storage::cloud_blob_container container = blob_client.get_container_reference(U("image-container"));
azure::storage::cloud_block_blob blockBlob = container.get_block_blob_reference(U("28bbcdb0b3e5417b207572e292ae98412cd9d931eae6266f7c4fd788ad8544a20.jpg"));
concurrency::streams::istream input_stream = concurrency::streams::file_stream<uint8_t>::open_istream(U("image.jpg")).get();
blockBlob.upload_from_stream(input_stream);
input_stream.close().wait();
}
catch (const std::exception& e)
{
std::wcout << U("Error: ") << e.what() << std::endl;
}
}
Build.cs content
public class Program : ModuleRules
{
public Program(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
//I tried to use ansi allocator but it did not help
//PublicDefinitions.Add("FORCE_ANSI_ALLOCATOR");
PublicIncludePaths.Add(Path.Combine(DependencyFolderWin, "include"));
PublicAdditionalLibraries.Add(Path.Combine(DependencyFolderWin, "lib", "wastorage.lib"));
PublicAdditionalLibraries.Add(Path.Combine(DependencyFolderWin, "lib", "cpprest_2_10.lib"));
PublicAdditionalLibraries.Add(Path.Combine(DependencyFolderWin, "lib", "brotlicommon.lib"));
PublicAdditionalLibraries.Add(Path.Combine(DependencyFolderWin, "lib", "brotlidec.lib"));
PublicAdditionalLibraries.Add(Path.Combine(DependencyFolderWin, "lib", "brotlienc.lib"));
PublicAdditionalLibraries.Add(Path.Combine(DependencyFolderWin, "lib", "zlib.lib"));
}
private string DependencyFolderWin
{
get
{
string moduleDir = Path.GetFullPath(ModuleDirectory);
return Path.Combine(moduleDir, "./../../deps");
}
}
}
Проблема в том, что он успешно загружает изображение и вылетает сразу после возврата из этой функции ( в этом случае StartPlay () или Upload () как в стеке вызовов) с этим стеком вызовов:
UE4Editor-Core.dll!00007ff9e620ff1b() Unknown
UE4Editor-Core.dll!00007ff9e62109e3() Unknown
UE4Editor-Core.dll!00007ff9e6211592() Unknown
UE4Editor-Core.dll!00007ff9e5e95277() Unknown
[Inline Frame] UE4Editor-MsgQueuePlugin.dll!operator delete(void *) Line 31 C++
[Inline Frame] UE4Editor-MsgQueuePlugin.dll!std::_Deallocate(void * _Ptr, unsigned __int64 _Bytes) Line 207 C++
[Inline Frame] UE4Editor-MsgQueuePlugin.dll!std::allocator<wchar_t>::deallocate(wchar_t * const) Line 992 C++
UE4Editor-MsgQueuePlugin.dll!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >::_Tidy_deallocate() Line 3992 C++
[Inline Frame] UE4Editor-MsgQueuePlugin.dll!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >::{dtor}() Line 2460 C++
UE4Editor-MsgQueuePlugin.dll!web::uri::~uri() C++
UE4Editor-MsgQueuePlugin.dll!azure::storage::cloud_blob::~cloud_blob() C++
UE4Editor-MsgQueuePlugin.dll!AzureUploader::Upload(TArray<unsigned char,FDefaultAllocator> file, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & path, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & fileName) Line 37 C++
Callstack с символами отладки редактора:
[Inline Frame] UE4Editor-Core.dll!__TBB_machine_cmpswp1(volatile void *) Line 69 C++
[Inline Frame] UE4Editor-Core.dll!__TBB_TryLockByte(unsigned char &) Line 917 C++
UE4Editor-Core.dll!__TBB_LockByte(unsigned char & flag) Line 924 C++
[Inline Frame] UE4Editor-Core.dll!MallocMutex::scoped_lock::{ctor}(MallocMutex &) Line 66 C++
UE4Editor-Core.dll!rml::internal::Block::freePublicObject(rml::internal::FreeObject * objectToFree) Line 1382 C++
[Inline Frame] UE4Editor-Core.dll!rml::internal::internalPoolFree(rml::internal::MemoryPool * memPool, void *) Line 2571 C++
UE4Editor-Core.dll!rml::internal::internalFree(void * object) Line 2595 C++
UE4Editor-Core.dll!FMemory::Free(void * Original) Line 76 C++
[External Code]
UE4Editor-MsgQueuePlugin.dll!AzureUploader::Upload(TArray<unsigned char,FDefaultAllocator> file, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & path, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & fileName) Line 37 C++
Похоже, что происходит сбой при удалении URI из какой-то структуры. Возможно, проблема в нереальном управлении памятью. Я пытался использовать ansi allocator, но это не помогло. Любые идеи, как заставить это работать должным образом? Спасибо