Skip to content

Call to enable_result_type_inference is not safe #275

@Danacus

Description

@Danacus

Calling enable_result_type_inference on OperationBuilder may trigger undefined behavior if types cannot be inferred, since mlirOperationCreate returns a nullptr in this case. OperationBuilder::build does not check for nullity, and as such an invalid Operation may be constructed, causing undefined behavior when it is accessed or dropped.

Code to reproduce:

{
    let _ = OperationBuilder::new("test", location)
        .enable_result_type_inference()
        .build();
}

Suggested fix: check for nullity before calling Operation::from_raw in OperationBuilder::build and return a Result<Operation, _> or simply panic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions