iOS std::string 因为内存分配器使用导致部分机型系统出现崩溃

重现步骤
Exception Type: EXC_CRASH

Exception Codes: 0x0000000000000000, 0x0000000000000000

Exception signal: SIGABRT

triggered

thread queue 53771 com.apple.main-thread

0 libsystem_kernel.dylib 0x1e690c1dc 0x1e6901000+0xb1dc __pthread_kill+8

1 libsystem_pthread.dylib 0x21fc12c60 0x21fc0b000+0x7c60 pthread_kill+268

2 libsystem_c.dylib 0x19ccc92d0 0x19cc52000+0x772d0 abort+124

3 libsystem_malloc.dylib 0x1a560ad7c 0x1a55f4000+0x16d7c malloc_vreport+892

4 libsystem_malloc.dylib 0x1a560a9f4 0x1a55f4000+0x169f4 malloc_report+64

5 libsystem_malloc.dylib 0x1a56055a0 0x1a55f4000+0x115a0 ___BUG_IN_CLIENT_OF_LIBMALLOC_POINTER_BEING_FREED_WAS_NOT_ALLOCATED+32

6 libc++.1.dylib 0x1a58d4ac4 0x1a58bc000+0x18ac4 std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::~basic_string()+44

7 UAGame 0x105ef6d70 0x104ab4000+0x1442d70 G6ToolKit::google::protobuf::SimpleDescriptorDatabase::DescriptorIndex<std::__1::pair<void const*, int> >::AddFile(G6ToolKit::google::protobuf::FileDescriptorProto const&, std::__1::pair<void const*, int>) + 332+332

8 UAGame 0x105ef6b74 0x104ab4000+0x1442b74 G6ToolKit::google::protobuf::EncodedDescriptorDatabase::Add(void const*, int) + 108+108

9 UAGame 0x105ead898 0x104ab4000+0x13f9898 G6ToolKit::google::protobuf::DescriptorPool::InternalAddGeneratedFile(void const*, int) + 48+48

10 UAGame 0x105eddd6c 0x104ab4000+0x1429d6c G6ToolKit_protobuf_google_2fprotobuf_2fdescriptor_2eproto::AddDescriptorsImpl() + 28+28

11 UAGame 0x105f2c5dc 0x104ab4000+0x14785dc G6ToolKit::google::protobuf::internal::FunctionClosure0::Run() + 28+28

12 UAGame 0x105f2de04 0x104ab4000+0x1479e04 G6ToolKit::google::protobuf::GoogleOnceInitImpl(long*, G6ToolKit::google::protobuf::Closure*) + 112+112

13 UAGame 0x105fc7f80 0x104ab4000+0x1513f80 G6ToolKit::google::protobuf::GoogleOnceInit(long*, void (*)()) + 64+64

14 UAGame 0x105ef4d88 0x104ab4000+0x1440d88 G6ToolKit_protobuf_google_2fprotobuf_2fdescriptor_2eproto::StaticDescriptorInitializer::StaticDescriptorInitializer() + 20+20

15 dyld 0x1bc5ede58 0x1bc5b8000+0x35e58 invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const+624

16 dyld 0x1bc62ac2c 0x1bc5b8000+0x72c2c invocation function for block in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const+172

​这是项目接入protobuf然后在iOS 18.5的开发版本出现的闪退,游戏启动不了,回想还有很多类似的a静态库,工作量不少,稳定性也没有保障

请问UE这边有提供比较权威的解决方案吗,华为的系统也有类似的问题,AI的建议是通过

// YourProject.Build.cs if (Target.Platform == UnrealTargetPlatform.IOS) { // 直接添加链接器参数 PublicAdditionalLibraries.Add("-Wl,-alias,_UE4Malloc,_malloc"); PublicAdditionalLibraries.Add("-Wl,-alias,_UE4Free,_free"); }// MyMemoryBridge.cpp

include “HAL/MemoryBase.h”

extern “C” {

void* UE4Malloc(size_t Size) {

return FMemory::Malloc(Size);

}

void UE4Free(void* Ptr) {

FMemory::Free(Ptr);

}

}

来替换a静态库的​连接解决问题,这个应该挺好的,不知道UE这边有提供这种方案吗