Skip to content

Primitive reference type crashes corto_value_binaryOp #689

@SanderMertens

Description

@SanderMertens

When the following cortoscript code is parsed:

int ref_i32: width_32, reference: true

struct Point {
    x, y: ref_i32
}

ref_i32 a, b: 10

Point p = {a, b}

it crashes with this stack trace:

==11195== Invalid read of size 4
==11195==    at 0x4EB591F: _corto_assert_object (bootstrap.c:1495)
==11195==    by 0x4E8DF5A: corto_set_ref (object.c:5372)
==11195==    by 0x4EAF2F1: corto_intern_binaryOp (operator.c:484)
==11195==    by 0x4EAF5EA: corto_ptr_binaryOp (operator.c:518)
==11195==    by 0x4EB2F3B: corto_value_binaryOp (value.c:1012)
==11195==    by 0x4EB7586: corto_rw_set_value (rw.c:804)
==11195==    by 0x6A4E4C8: _corto_script_ast_Initializer_apply (Initializer.cpp:38)
==11195==    by 0x6C7EE1C: _corto_script_declare_Visitor_visitDeclaration (Visitor.c:301)
==11195==    by 0x6A5A9B2: _corto_script_ast_Visitor_visit (Visitor.cpp:19)
==11195==    by 0x6A5B8BD: _corto_script_ast_Visitor_visitScope_v (Visitor.cpp:98)
==11195==    by 0x6C7F326: _corto_script_declare_Visitor_visitScope (Visitor.c:372)
==11195==    by 0x6A5A826: _corto_script_ast_Visitor_visit (Visitor.cpp:14)
==11195==  Address 0xfffffffffffffff2 is not stack'd, malloc'd or (recently) free'd

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions