Characters become crazy code in the middle of a string when it's passed into a function in libraries on Unix system in development build

There is a structure called Aws::Auth::AwsCredentials in the library I’m using. When Aws::Auth::AwsCredentials structure in aws sdk is passed into library, the first variable in it which is a std::string will become crazy code from 7th character to 15th characters in UE5 (tested from 5.0.1-release to 5.1.0-release). The crazy code always starts with 0x18 and ends with 0x1000. It works normally on debug build for Mac and iOS platform, but this issue will appear in the other build on Mac and iOS platform and all build on Android. And I don’t have different libraries for each build type.
Because it didn’t happen on 4.27 and after adding another variable before awsCredentials or add a dummy variables as Aws::Auth::AwsCredentials’s first parameter can bypass this issue. I think it might relate to UE5 memory management.
please tell me your thoughts. Thanks.

we have made a small project to reproduce this issue for Mac. UE5Bug.zip - Google Drive
It also includes a pre-built debug and development build. so that you can just run the app and check the log. search for “Signing request with: AWS4-HMAC-SHA256”, you will find that the credential after this string became crazy code in the middle in development build and works fine in debug build.
please download and test it on Mac.
and a video shows how this issue looks like.
A weird bug on UE5 on unix platform. - YouTube

In the debugger you can set a write watchpoint on the string just before it gets corrupted, and then when the debugger breaks you can see what is on the stack and writting the “crazy code” into the string.

after a few days of research, unreal’s memory system conflicts with posix_memalign.
However, it’s still not fixed. After removing all posix_memalign in the project, the string length will become 0 after passing it as a const refer to a function in library. There is still some weird bugs in unreal’s memory module.


from what I have learned, std::string uses short mode for string less than 22 characters and the access key id has 20 characters. So, it uses short mode. in short mode, string’s size is stored in a byte. But now it’s changed after the string is passed to a function as a const reference in the shared library. But the content is still there. I can’t come up with any idea what could cause this issue.

any idea will be appreciated. please help me.

Did you try setting a watchpoint like I suggested?

breakpoint may not help much in this case. it’s changed suddenly when it’s passed to a function as const reference in a shared library, which means it shouldn’t be changed in the shared library. So, if you debug in unreal side’s code, you will just see the string’s size is changed to 0 from 40 between 2 steps. as you can see in the screenshot I provide.
If I just test the shared library without unreal, it works normally and it works on UE4 as well. the problem is not from the shared library.


A watchpoint and a breakpoint are different. A watchpoint is set on some memory, and when that memory is read or written the debugger breaks. A breakpoint is set on a line of code (instruction), and when that line of code is executed the debugger breaks. What IDE are you using? Visual Studio? See here c++ - Automatic break when contents of a memory location changes or is read - Stack Overflow

I believe they are called data breakpoints in visual studio.

Also do you not have debug symbols for the shared library? You should be able to step into a shared library if you have debug symbols loading for it.

I’m not unreal staff. If you think you’ve discovered a bug in unreal engine then the place to report it is here: Report a Bug - Unreal Engine

please delete this topic.