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

Assertion 'ecma_is_completion_value_empty (completion)' failed in ecma_op_function_declaration #195

Closed
renatahodovan opened this issue Jun 16, 2015 · 2 comments
Labels
bug Undesired behaviour ecma core Related to core ECMA functionality normal

Comments

@renatahodovan
Copy link
Contributor

Jerry version:
Checked revision: 8a9633d
Build: debug.linux
OS:
Ubuntu 14.10, x86_64
Test case:
function Error() {}
Backtrace:
ICE: Assertion 'ecma_is_completion_value_empty (completion)' failed at jerryscript/jerry-core/ecma/operations/ecma-function-object.cpp(ecma_op_function_declaration):953.
Error: ERR_FAILED_INTERNAL_ASSERTION

Program received signal SIGABRT, Aborted.
0x000000000047c32b in syscall_2_asm () at jerryscript/jerry-libc/target/linux/jerry-asm.S:32
32    SYSCALL_2
(gdb) bt
#0  0x000000000047c32b in syscall_2_asm () at jerryscript/jerry-libc/target/linux/jerry-asm.S:32
#1  0x00000000004003c2 in syscall_2 (syscall_no=62, arg1=9459, arg2=6)
    at jerryscript/jerry-libc/target/linux/jerry-libc-target.c:105
#2  0x0000000000400563 in abort () at jerryscript/jerry-libc/target/linux/jerry-libc-target.c:184
#3  0x0000000000435329 in jerry_fatal (code=ERR_FAILED_INTERNAL_ASSERTION) at jerryscript/jerry-core/jrt/jrt-fatals.cpp:70
#4  0x0000000000435378 in jerry_assert_fail (assertion=0x48e628 "ecma_is_completion_value_empty (completion)", 
    file=0x48e410 "jerryscript/jerry-core/ecma/operations/ecma-function-object.cpp", 
    function=0x480c90 <_ZZ28ecma_op_function_declarationP13ecma_object_tP13ecma_string_tPK8opcode_ttPS2_tbbbE8__func__.lto_priv.564> "ecma_op_function_declaration", line=953) at jerryscript/jerry-core/jrt/jrt-fatals.cpp:97
#5  0x000000000044403e in ecma_op_function_declaration (lex_env_p=0x7a77e8 <_ZL13mem_heap_area.lto_priv.972+40>, 
    function_name_p=0x7a77f8 <_ZL13mem_heap_area.lto_priv.972+56>, opcodes_p=0x7a7a18 <_ZL13mem_heap_area.lto_priv.972+600>, 
    function_code_opcode_idx=5, formal_parameter_list_p=0x0, formal_parameter_list_length=0, is_strict=false, do_instantiate_arguments_object=false, 
    is_configurable_bindings=false) at jerryscript/jerry-core/ecma/operations/ecma-function-object.cpp:953
#6  0x0000000000432030 in function_declaration (int_data=0x7fffffffd400, function_name_lit_cp=..., args_names=0x0, args_number=0)
    at jerryscript/jerry-core/vm/opcodes.cpp:476
#7  0x0000000000432103 in opfunc_func_decl_n (opdata=..., int_data=0x7fffffffd400) at jerryscript/jerry-core/vm/opcodes.cpp:512
#8  0x000000000047988a in vm_loop (int_data_p=0x7fffffffd400, run_scope_p=0x0) at jerryscript/jerry-core/vm/vm.cpp:471
#9  0x0000000000479b17 in vm_run_from_pos (opcodes_p=0x7a7a18 <_ZL13mem_heap_area.lto_priv.972+600>, start_pos=1, this_binding_value=15, 
    lex_env_p=0x7a77e8 <_ZL13mem_heap_area.lto_priv.972+40>, is_strict=false, is_eval_code=false)
    at jerryscript/jerry-core/vm/vm.cpp:561
#10 0x0000000000479710 in vm_run_global () at jerryscript/jerry-core/vm/vm.cpp:395
#11 0x000000000047be39 in jerry_run () at jerryscript/jerry-core/jerry.cpp:1265
#12 0x000000000047aa89 in main (argc=3, argv=0x7fffffffd798) at jerryscript/main-linux.cpp:252
@ruben-ayrapetyan ruben-ayrapetyan added bug Undesired behaviour normal ecma core Related to core ECMA functionality labels Jun 17, 2015
@galpeter
Copy link
Contributor

Root cause of the problem:
The Error is a built-in function/object thus when the ecma_op_function_declaration is called there is a case when the method checks if it is already there and then does an ecma_op_object_define_own_property call, which returns ECMA_SIMPLE_VALUE_TRUE on success and not an empty value.

Speculative fix:

diff --git a/jerry-core/ecma/operations/ecma-function-object.cpp b/jerry-core/ecma/operations/ecma-function-object.cpp
index ebbca81..eddf9b3 100644
--- a/jerry-core/ecma/operations/ecma-function-object.cpp
+++ b/jerry-core/ecma/operations/ecma-function-object.cpp
@@ -950,7 +950,8 @@ ecma_op_function_declaration (ecma_object_t *lex_env_p, /**< lexical environment
   }
   else
   {
-    JERRY_ASSERT (ecma_is_completion_value_empty (completion));
+    JERRY_ASSERT (ecma_is_completion_value_empty (completion)
+                  || ecma_is_completion_value_normal_simple_value (completion, ECMA_SIMPLE_VALUE_TRUE));

     // f.
     ret_value = ecma_op_set_mutable_binding (lex_env_p,

@galpeter
Copy link
Contributor

Closing as it is fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Undesired behaviour ecma core Related to core ECMA functionality normal
Projects
None yet
Development

No branches or pull requests

4 participants