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

h_cfgrammar_() leaks memory #182

Open
puellavulnerata opened this issue Dec 6, 2016 · 2 comments
Open

h_cfgrammar_() leaks memory #182

puellavulnerata opened this issue Dec 6, 2016 · 2 comments

Comments

@puellavulnerata
Copy link

While valgrinding unit tests and plugging leaks, I found that /core/grammar/end leaks even if I add h_cfgrammar_free(g) to test_end(). The cause is the calls to h_new() (rather than in the grammar's arena) in if (h_hashset_empty(g->nts)) branch of h_cfgrammar_(). Unfortunately, these cannot simply be changed over to h_arena_malloc() calls because the LL(k) backend frees the grammar once it finishes compiling the parser, but apparently keeps some of these pointers around and uses them during parsing. Further investigation proceeding.

@puellavulnerata
Copy link
Author

I believe, tentatively, that the underlying problem here is that collect_nts() relies on the desugared field of the parser nodes, so each HCFChoice there is freed along with the corresponding parser, but in the case where desugared is a terminal we wrap it, and the resulting wrapper HCFChoice does not appear anywhere in the parser, only in the grammar, and so never gets freed.

@pesco
Copy link

pesco commented Dec 6, 2016 via email

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

2 participants