Skip to content

Fix memory leak when using continue or break statement with syntaxError#5190

Open
gergocs wants to merge 1 commit into
jerryscript-project:masterfrom
gergocs:fixIssue5062
Open

Fix memory leak when using continue or break statement with syntaxError#5190
gergocs wants to merge 1 commit into
jerryscript-project:masterfrom
gergocs:fixIssue5062

Conversation

@gergocs

@gergocs gergocs commented Dec 9, 2024

Copy link
Copy Markdown
Contributor

This patch fixes #5062.

JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi gergocs@inf.u-szeged.hu

@gergocs gergocs force-pushed the fixIssue5062 branch 2 times, most recently from 11547fa to e37002c Compare December 9, 2024 09:58
@gergocs gergocs marked this pull request as ready for review December 9, 2024 09:58

@zherczeg zherczeg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Title: whit -> with

Comment thread jerry-core/parser/js/js-parser-statm.c Outdated
@gergocs gergocs changed the title Fix memory leak when using continue or break statement whit syntaxError Fix memory leak when using continue or break statement with syntaxError Dec 9, 2024
@gergocs gergocs requested a review from zherczeg December 9, 2024 12:21
@zherczeg

zherczeg commented Dec 9, 2024

Copy link
Copy Markdown
Member

Does this patch increase memory consumption in the normal (no parse error) case?

@gergocs

gergocs commented Dec 9, 2024

Copy link
Copy Markdown
Contributor Author

Yes it does. For example the regression-test-issue-1555.js test fails if the heap size is not increased.

@zherczeg

zherczeg commented Dec 9, 2024

Copy link
Copy Markdown
Member

Would it be possible to free the memory at its regular place as well?

@gergocs

gergocs commented Dec 9, 2024

Copy link
Copy Markdown
Contributor Author

I don't think so. I have debugging this issue a very long time and didn't find any better methods to keep track of possible non freed pointers.

@zherczeg

zherczeg commented Dec 9, 2024

Copy link
Copy Markdown
Member

I mean when a pointer is not needed, it could be removed from the tracker and free it. I suspect we keep pointers too long around this way.

@gergocs gergocs force-pushed the fixIssue5062 branch 2 times, most recently from 0bf29cb to 66c17dd Compare December 11, 2024 07:52
This patch fixes jerryscript-project#5062.

JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi gergocs@inf.u-szeged.hu
@zherczeg

Copy link
Copy Markdown
Member

parser_raise_error (parser_context_t *context_p, /**< context */

The parser already does a lot of cleanup on throw. If we could put this branch list into some local context (a chain list with a head), we could cleanup it without complex structures.

@gergocs

gergocs commented Dec 11, 2024

Copy link
Copy Markdown
Contributor Author

Currently it is a chain list not a complex structure and stored in the context to easily pass around.

@zherczeg

Copy link
Copy Markdown
Member

Not the complexity, but it has while loops. The design is better if less scanning is needed.

Is it operating like a stack btw? So we usually remove items form the end?

@gergocs

gergocs commented Dec 11, 2024

Copy link
Copy Markdown
Contributor Author

No, it's not like stack.

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.

Assertion 'JERRY_CONTEXT (jmem_heap_allocated_size) == 0' failed at jerryscript/jerry-core/jmem/jmem-heap.c(jmem_heap_finalize):108.

2 participants