Hello,
I’m working in an Unreal Engine 5.3.2 environment with Protobuf 3.21.12, and I’m investigating an issue where a crash occurs only on iOS in the destructor of a repeated string
field.
Current Setup
- LocalPlayer TMap
TMap<FString, FRealStruct> PlayerData;
FRealStruct
hasFString GetString() const;
- The TMap is populated at login time
- UI ListView
- Items are created with
NewObject<UMyItem>
and added to the ListView - Each item stores
UPROPERTY() FMyStruct MyStruct;
- The currently selected item is stored as
UPROPERTY() UMyItem* MyItem;
- Packet Preparation
- Retrieve a TMap value, make a deep copy via
FString Temp(MyString)
- Add it to a static
TArray
- Convert the
TArray
intostd::vector<std::string>
and assign to the Protobuf message’srepeated string
field - The message itself is created as a stack variable
- Issue
- Even without sending the packet, a crash occurs in the message’s destructor
- The crash happens only on iOS; it does not occur on Windows/Android
- Tried Arena messages, heap allocation, assign via temporary vectors, etc. — all result in the same crash
Additional Information
- Whether returning
const FString&
orFString
, the same issue occurs - LocalPlayer TMap, ListView Items, and the static
TArray
could potentially be accessed concurrently (multithreading involved) - The root cause is suspected to be a conflict between the Protobuf repeated string destructor and UE FString/TArray internal buffer, or iOS-specific allocator behavior
- If the TMap’s memory is corrupted, it seems plausible that the crash would manifest only on iOS
Questions
- Is it reasonable to assume that the crash occurring only on iOS is due to a conflict between the Protobuf repeated string destructor and UE FString/TArray memory management?
- When copying a TMap value’s FString into a TArray and then assigning it to a repeated string, what is the recommended pattern to ensure no shallow copy occurs and it is handled safely?
- Given that I must use Protobuf 3.21.x, is there a way or design pattern to safely use
repeated string
on iOS without crashes? - Are there any references to known cases of iOS crashes with repeated string (documentation, GitHub issues, Google Groups discussions) that you can point me to?