exml_event.c: enif_open_resource_type for "parser_pointer" does not specify the destructor function. #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The following snippet contains some helper funs I would like to use to demonstrate the issue.
Just paste them into your REPL: https://gist.github.com/RGafiyatullin/675b97dc76c69d8a7c00 .
The leaky case (current
esl/master
): https://gist.github.com/RGafiyatullin/9cefce33bb22f3350cf0 .The fixed case (current
RGafiyatullin/master
): https://gist.github.com/RGafiyatullin/4b895d6282b43d78dc42 .Bits of reasoning:
exml_event:free_parser/1
usage is not an option as it is a slightly less expected behaviour rather than a proper resource cleanup upon garbage collection. (The iodevices / ets's / dets's / you-name-it's usually get disposed upon the owner's termination ).exml_event:free_parser/1
being bound toexml_event:reset_parser/1
is IMHO a necessity since any attempt to useexml_event:parse/2
with the resource being previously freed leads to a VM crash. The ErlangVM is not expected to crash with a segfault in case of a mistake in Erlang code.