Skip to content

[asan] failure to detect memory leaks #129842

Open
@PikachuHyA

Description

@PikachuHyA

reproducer
see https://godbolt.org/z/6YGdnn634

// main.cc
struct Foo {
  struct Foo *other;
};
int main() {
  auto f1 = new Foo();
  auto f2 = new Foo();
  f1->other = f2;
  f2->other = f1;
  return 0;
}

However, the following memory leaks detected.

see https://godbolt.org/z/n6jWbYTqY

struct Foo {
  struct Foo *other;
};
int main() {
  auto f1 = new Foo();
  auto f2 = new Foo();
  f1->other = f2;
  // highlight here
  // f2->other = f1;
  return 0;
}

Note: GCC can detect the memory leaks.
if use -fsanitize=leak, the memory leaks detected.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions