std::string Crashes

I’ve been using Pulse with Unreal Engine 5.0, and recently updated to the latest changeset on Stable branch (back from changesets in December '23). I’m not sure what has changed, but now whenever I pass in an std::string parameter from my C++ Unreal Engine code to a function in the Pulse DLL, I get a crash. Using the Pulse debug DLLs I can see that Pulse is unable to read the memory contained in the strings. If I refactor these functions in the DLL to use char* everything works as expected.

Is there any specific reason why std::string was chosen for the public functions? Is there any notable change since December that might be causing the DLLs to compile differently? I’ve made sure both Unreal and the DLLs are using the same C++ standard (20).

We chose to use stardard C++ structures in our interface when we started BioGears ~2014

We are now compiling the plugin DLL with C++17, not 20
Are you building Pulse yourself? If so, what branch?

So this new unreal plugin is now using a dynamic library rather than a static library from the previous version.

Is there anyway you can create something that reproduces this issue using our example project?
https://gitlab.kitware.com/physiology/unreal/-/tree/main/PulsePhysiologyEngine?ref_type=heads

I’m compiling Pulse myself, yes. I’m on the Stable branch. I changed it to compile with C++20 in order to match my Unreal Engine project. Do you foresee this causing any issues? The issues I face are the same regardless of what version I use.

If I can’t find a solution I will try to create a project that reproduces the issue.

I have not built Pulse with C++20, I am not sure how it will act with that standard

I know that Unreal does not like using many of the C++ standard libraries
I am not sure what kind of compiler options it recommends when you do use them…

It sounds like some kind of dll boundary issue where different standard definitions are being used between Unreal and Pulse for some reason

I would start with confirming that Pulse is ok with C++20
Then figure out if Unreal has any recommendations when using a 3rd party C++ library in its C++20 documentation…

A quick update here
You need to build the full Pulse build with C++20 (including our dependencies)
So you will have to change the standard to 20 in our CMakeLists.txt

I tried that, and our current protobuf version that we pull (25.2) has issues with C++20 that were addressed in version 26.0, which also has some other updates that affect the pulse build…

So, I assume you maybe only changed the Pulse Innerbuild to 20?

At any rate, I will put this on the list, but I don’t know how long it will be to get all the C++20 build issues addressed…

Many thanks for your help. I think it must have been a combination of trying to use Pulse debug DLLs and some other changes I made during the update. I went back to pre-upgrade on old Pulse changesets and re-did everything. With release DLLs most things are now working ok, but I cannot use debug DLLs, I’m not sure if I’m doing something wrong or if the standard libraries become incompatible when compiling in this way, which isn’t too uncommon in this context.

The use of standard libraries in DLL public functions are still proving to be an obstacle, but I’m able to re-write the Pulse functions we use or use workarounds to avoid standard library data structures where required. Currently there is just one inconsistent crash related to PhysiologyEngine::SerializeToString, hopefully after that my issue will be resolved. I completely understand that my team are a small part of many Pulse users, but for us these std features for public DLL functions have been very difficult to work with.

You could try interfacing directly with our C interface, or use it as a base for an even simpler interface
You can just create the json structures manually it expects

Thanks Aaron, we will investigate these approaches as an alternative.