Skip to content

clang++ shared_ptr with control flow integrity crashes #52652

Open
@ambiso

Description

@ambiso

The following program:

#include <memory>

struct X {
    X() {}
    virtual ~X() {};
};

int main() {
    std::shared_ptr<X> _asd = std::make_shared<X>();
    return 0;
}

Compiled with:

$ clang++ -fsanitize=cfi-unrelated-cast -fvisibility=hidden -flto -O2 -std=c++14 test.cc

on

$ clang++ --version
clang version 13.0.0
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

crashes:

$ ./a.out
[1]    21670 illegal hardware instruction (core dumped)  ./a.out

I don't see any reason that it should crash - am I doing something wrong?

Here's the gef context one instruction before the crashing instruction (ud1):
gef-context

Please let me know if there's any more information that I could provide!
Best,
ambiso

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