Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialization of a std::map<std::string, ChLinkTSDA> leads to a segmentation fault #507

Open
paulotto opened this issue Jul 12, 2024 · 0 comments

Comments

@paulotto
Copy link

paulotto commented Jul 12, 2024

Hi everyone,

I tried to serialize a class member of type std::map<std::string, ChLinkTSDA> with archive_out << CHNVP(map_);, but unfortunately, this led to a segmentation fault.

While looking for the cause of this, I came across another issue, which I wondered if was related to the first issue. If you want to do something like this

std::map<std::string, ChLinkTSDA> map_{
    {"l1", ChLinkTSDA()}
};

a 'bad_alloc' exception is thrown. I could eliminate this by adding the following line to the copy constructor of ChLinkTSDA:

m_jacobians = other.m_jacobians ? new SpringJacobians(*other.m_jacobians) : nullptr;

and change the copying of m_variables to:

m_variables = other.m_variables ? new ChVariablesGenericDiagonalMass(*other.m_variables) : nullptr;

But in the end, I couldn't solve the serialization problem. Maybe you have a solution.

Thanks and best regards,
Paul

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant