Skip to content

Fix "unhandled exception occurs when a private variable increments" #5239

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

hvwyl
Copy link

@hvwyl hvwyl commented Jul 11, 2025

Fix "unhandled exception occurs when a private variable increments" #5238

Added handling for the condition of private variable incr/decr in js-parser-expr.c and vm.c.

JerryScript-DCO-1.0-Signed-off-by: hvwyl 594352301@qq.com

@zherczeg
Copy link
Member

Thank you! Could you add a test case?

@hvwyl
Copy link
Author

hvwyl commented Jul 11, 2025

Thank you! Could you add a test case?

ok, i have added the test case for issue #5238

Copy link
Member

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

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

LGTM

}
}
var var19 = new R();
var19.test();
Copy link
Member

Choose a reason for hiding this comment

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

Add a newline at the end.

@hvwyl
Copy link
Author

hvwyl commented Jul 12, 2025

LGTM

a newline at the end of file private_fields.js has been added. and it can be merged directly.

@hvwyl hvwyl requested a review from zherczeg July 13, 2025 03:22
@zherczeg
Copy link
Member

Somehow these tests are crashing, e.g. FAIL (-6): tests/jerry/private_fields.js

@hvwyl
Copy link
Author

hvwyl commented Jul 13, 2025

Somehow these tests are crashing, e.g. FAIL (-6): tests/jerry/private_fields.js

I checked the latest commit of branch. Files private_field.js and regression-test-issue-5238.js are ok.

I noticed that the crushing dosen't occur in release version, and it only occurs in debug version.

Then I compiled the debug version in vm.

For input class A { #a = 0; incr() { this.#a++ } }, it raises

ICE: Assertion 'context_p->stack_depth == 0' failed at /home/runner/work/jerryscript/jerryscript/jerry-core/parser/js/js-parser.c(parser_post_processing):635.
Error: JERRY_FATAL_FAILED_ASSERTION

The real reason is that context_p->stack_depth will be decremented by 1 after context_p->last_cbc_opcode = PARSER_PUSH_PROP_LITERAL_TO_PUSH_LITERAL (context_p->last_cbc_opcode); (located in js-parser-expr.c)

But context_p->stack_depth will remain the same after context_p->last_cbc_opcode = PARSER_TO_EXT_OPCODE (CBC_EXT_PUSH_PRIVATE_PROP_LITERAL_REFERENCE); (located in js-parser-expr.c).

The way to fix: Manually adjusting stack usage for private-field condition.

However, for release version, assert will be disabled. So I didn't notice this crushing.

In addition, I'm using a nickname on github. So I updated the comment in order to fit signed-off checking. Should I resubmit the pr?

@zherczeg
Copy link
Member

There is no need for a second pr.

@hvwyl
Copy link
Author

hvwyl commented Jul 13, 2025

There is no need for a second pr.

I noticed the Checks in Action #4395, it throw

Signed-off-by message is incorrect. The following line should be at the end of the 71a898cb commit's message: 'JerryScript-DCO-1.0-Signed-off-by: hvwyl 594352301@qq.com'. 

although I have updated the comment 2 days ago. I don't know if this can be ignored.

Anyway, Win_x86-64_Tests-MINGW in Action #4395. There's also problem in ecma-builtin-helpers-date.c.

@hvwyl
Copy link
Author

hvwyl commented Jul 13, 2025

Somehow these tests are crashing, e.g. FAIL (-6): tests/jerry/private_fields.js

I checked the latest commit of branch. Files private_field.js and regression-test-issue-5238.js are ok.

I noticed that the crushing dosen't occur in release version, and it only occurs in debug version.

Then I compiled the debug version in vm.

For input class A { #a = 0; incr() { this.#a++ } }, it raises

ICE: Assertion 'context_p->stack_depth == 0' failed at /home/runner/work/jerryscript/jerryscript/jerry-core/parser/js/js-parser.c(parser_post_processing):635.
Error: JERRY_FATAL_FAILED_ASSERTION

The real reason is that context_p->stack_depth will be decremented by 1 after context_p->last_cbc_opcode = PARSER_PUSH_PROP_LITERAL_TO_PUSH_LITERAL (context_p->last_cbc_opcode); (located in js-parser-expr.c)

But context_p->stack_depth will remain the same after context_p->last_cbc_opcode = PARSER_TO_EXT_OPCODE (CBC_EXT_PUSH_PRIVATE_PROP_LITERAL_REFERENCE); (located in js-parser-expr.c).

The way to fix: Manually adjusting stack usage for private-field condition.

However, for release version, assert will be disabled. So I didn't notice this crushing.

In addition, I'm using a nickname on github. So I updated the comment in order to fit signed-off checking. Should I resubmit the pr?

This issue has been solved in the latest commit.

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.

2 participants