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

Add a workaround for enif_inspect_binary bug in ERTS < 9.0 #35

Merged
merged 1 commit into from
May 22, 2018

Conversation

kzemek
Copy link

@kzemek kzemek commented May 21, 2018

The bug caused previous results from enif_inspect_binary to sometimes be overwritten when calling enif_inspect_binary later. It was fixed in ERTS 9.0 which is included in Erlang 20+.

Copy link

@michalwski michalwski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm used to functional code so reading this was a bit challenging.
It's good the workaround is applied only when needed. I wonder what's the impact of the workaround in terms of consumed memory mostly. Did you measure it @kzemek?

class Version {
public:
Version(const std::string str) {
for (std::size_t i = 0; i < str.size();) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel old reading this modern C++ code and having difficulties to understand it easily.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i_hug_that_feel

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michalwski The strings are saved in RapidXML document's memory pool. We set the memory pool up to initial size of 10MB, and clear the pool before use in each NIF call. To have any impact on memory at all, the strings in a single #xmlel{} would have to take more than those 10MB.

@michalwski michalwski merged commit ecd4abd into master May 22, 2018
@michalwski michalwski deleted the enif_inspect_workaround branch May 22, 2018 08:06
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

Successfully merging this pull request may close these issues.

3 participants