-
Notifications
You must be signed in to change notification settings - Fork 685
fix bug of "deref bytecode twice" in jerry_exec_snapshot #1217
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
fix bug of "deref bytecode twice" in jerry_exec_snapshot #1217
Conversation
|
Thanks for the fix. Please add a unit test for this issue. |
|
LGTM |
| JERRY_ASSERT (sz == 20); | ||
| jerry_release_value (res); | ||
| JERRY_ASSERT (!strncmp (buffer, "string from snapshot", (size_t) sz)); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both global mode and eval mode will return the value of the last js statement. Is it what we expect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
|
LGTM |
|
@jiangzidong, please squash your commits and rebase to the current master, so I can land it properly. |
8de13ff to
ca39875
Compare
|
@LaszloLango done |
Enable the snapshot related test code in test-api.c JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
|
Actually, I think the unit-test-api.c can't perfectly detect we are derefing the bytecode which is already freed. I can't find a proper ASSERT to detect whether the bytecode_p is dangling pointer. Do you have any suggestion? |
|
I think this issue cannot be helped, since a memory allocator is free to do anything with the memory block after it is freed. A valgrind like "do not reuse memory" allocator could help, but that would require a new allocator for jerry. |
in
jerry_exec_snapshot, if the snapshot is is_run_eval, then the bytecode will deref invm_run_eval. Thejerry_exec_snapshotshouldn't call deref function aftervm_run_eval.JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com