Skip to content

Segmentation fault on program close #6

@ilumary

Description

@ilumary

Describe the bug
The program throws a segmentation fault on default exit.

To Reproduce
Paste the reproduction code snippet below:

#include "co_ecs.hpp"

struct s1 {
    uint32_t i1;
    uint64_t i2;
};

struct s2 {
    float f1;
    int i1;
};

struct s3 {
    char c, e;
};

void test_create(ecs::registry& reg) {
    auto a = reg.create<s1, s3>({1, 2}, {92, 93});
    auto b = reg.create<s1, s3>({7, 3}, {75, 76});
    auto c = reg.create<s2>({});
}

int main() {
    ecs::registry reg;
    test_create(reg);
    return 0;
}

Observed behavior
The segfault is caused by the destructor call inside the destructor of the chunk class. Specifically this line:

block.meta.type->destruct(_buffer + block.offset + i * block.meta.type->size);

Environment

  • OS: MacOS 13.1
  • Arch: arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions