jerryscript-project / jerryscript

Ultra-lightweight JavaScript engine for the Internet of Things.
https://jerryscript.net
Apache License 2.0
6.89k stars 669 forks source link

Assertion when debugging a class #4993

Open anzenkovich opened 2 years ago

anzenkovich commented 2 years ago

Built jerry script with debugger, wrote some js class and started session. Tried to expand "catch" section at first line of class definition, and debugger failed with message:

ICE: Assertion 'ecma_is_value_object (value)' failed at C:\work\jerryscript-master\jerryscript-master\jerry-core\debugger\debugger.c(jerry_debugger_get_variable_type):303.
Error: JERRY_FATAL_FAILED_ASSERTION

Also, I found another case with integer variable with property descriptor. Debugger can't understand that it is number value, but jerry_value_get_type() returns number type;

JerryScript revision

Release 2.4.0

Build platform

Windows, built with cmake on visual studio 2022, with enabled debugger

Test case

Input file test.js:

class MyClass
{
    constructor()
    {
        this.a = 6;
    }

    dd()
    {
        print(this.a)
    }
}

let x = new MyClass();
x.dd();
Backtrace
>   jerry.exe!jerry_port_fatal(jerry_fatal_code_t code) Line 32 C
    jerry.exe!jerry_fatal(jerry_fatal_code_t code) Line 66  C
    jerry.exe!jerry_assert_fail(const char * assertion, const char * file, const char * function, const unsigned int line) Line 84  C
    jerry.exe!jerry_debugger_get_variable_type(unsigned int value) Line 303 C
    jerry.exe!jerry_debugger_send_scope_variables(const unsigned char * recv_buffer_p) Line 504 C
    jerry.exe!jerry_debugger_process_message(const unsigned char * recv_buffer_p, unsigned int message_size, bool * resume_exec_p, unsigned char * expected_message_type_p, jerry_debugger_uint8_data_t * * message_data_p) Line 869    C
    jerry.exe!jerry_debugger_receive(jerry_debugger_uint8_data_t * * message_data_p) Line 1129  C
    jerry.exe!jerry_debugger_breakpoint_hit(unsigned char message_type) Line 1175   C
    jerry.exe!vm_loop(vm_frame_ctx_t * frame_ctx_p) Line 4640   C
    jerry.exe!vm_execute(vm_frame_ctx_t * frame_ctx_p) Line 5211    C
    jerry.exe!vm_run(vm_frame_ctx_shared_t * shared_p, unsigned int this_binding_value, ecma_object_t * lex_env_p) Line 5313    C
    jerry.exe!vm_run_global(const ecma_compiled_code_t * bytecode_p, ecma_object_t * function_object_p) Line 286    C
    jerry.exe!jerry_run(const unsigned int script) Line 548 C
    jerry.exe!jerryx_source_exec_script(const char * path_p) Line 68    C
    jerry.exe!main(int argc, char * * argv) Line 156    C